如何拷贝一个wchar_t类型的字符串

Do this,

wchar_t clone[260];

wcscpy(clone,szPath);

Or, if you want to allocate memory yourself,

wchar_t *clone = new wchar_t[wcslen(szPath)+1];

wcscpy(clone,szPath);

//use it

delete []clone;

Check out : strcpy, wcscpy, _mbscpy at MSDN

However, if your implementation doesn't necessarily require raw pointers/array, then you should prefer this,

#include<string>

 

//MOST SAFE!

std:wstring clone(szPath);

From: https://stackoverflow.com/questions/4540852/clone-a-wchar-t-in-c

原文地址:https://www.cnblogs.com/time-is-life/p/8485438.html