64,682
社区成员
发帖
与我相关
我的任务
分享
CString str = L"ABC";
wchar_t *wc = str.GetBuffer(str.GetLength());
char *c = new char[wcslen(wc)];
memset(c, 0, sizeof(c));
size_t iSize = wcstombs(c, wc, sizeof(c));
delete []c;
str.ReleaseBuffer();
//
iSize = 3;
c = "ABC";
CString str = _T("ABC");
TCHAR *c;
c = str.GetBuffer(str.GetLength());
_tprintf(_T("%d %s\n"),str.GetLength(), c);
char *sz=new char[str.GetLength()+1];
memset(sz,0,str.GetLength()+1);
wcstombs(sz,c,3);
printf("%d %s", strlen(sz),sz);
//不要忘了释放
delete[] sz;
str.ReleaseBuffer();
CString str = _T("ABC");
TCHAR *c;
c = str.GetBuffer(str.GetLength());
_tprintf(_T("%d %s"),str.GetLength(), c);