编程语言
首页 > 编程语言> > C/C++ 如何拷贝一个wchar_t类型的字符串

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

作者:互联网

 1 Do this,
 2 
 3 wchar_t clone[260];
 4 
 5 wcscpy(clone,szPath);
 6 
 7 Or, if you want to allocate memory yourself,
 8 
 9 wchar_t *clone = new wchar_t[wcslen(szPath)+1];
10 
11 wcscpy(clone,szPath);
12 
13 //use it
14 
15 delete []clone;
16 
17 Check out : strcpy, wcscpy, _mbscpy at MSDN
18 
19 However, if your implementation doesn't necessarily require raw pointers/array, then you should prefer this,
20 
21 #include<string>
22 
23 
24 //MOST SAFE!
25 
26 std:wstring clone(szPath);

 

标签:mbscpy,MSDN,clone,C++,wcscpy,szPath,wchar,拷贝
来源: https://www.cnblogs.com/ybqjymy/p/16595840.html