Achieve a wide character copy and calculate the length of a wide character
int Mywcslen (wchar_t *wstr) {int i = 0;while (*wstr!=l '} ') {i++;wstr++;} return i;} wchar_t *mywcscpy (wchar_t *dest, const wchar_t *source) {if (null==dest| | Null==source) {return NULL;} else{wchar_t *p = Dest;while (*dest++=*source++) {}return p;}} void Main () {setlocale (Lc_all, "ZH-CN");//Set Chinese wchar_t *p = (wchar_t[100]) {0};//stack on array c99 syntax wchar_t wch2[100] = L " Black Hawk-rocket "; int wlength = Mywcslen (WCH2); mywcscpy (P, WCH2); int wplength = Mywcslen (P);//The length after copy is also 9wprintf (L" \ N Length: wlength=%d wplength=%d string (p) =%ls\n ", Wlength, Wplength, p); system (" Pause ");}
Copyright NOTICE: This article is for bloggers original article, welcome to point out the code is bad, and put forward the Code optimization scheme. Welcome guidance, Night code, desperately struggling to update in ...
Implementation of the SYSTEM function C string: wcscpy and Wcslen