c++如何把char*转换成CString

来源:百度知道 编辑:UC知道 时间:2024/05/07 07:10:19

char * p = "This is a test";
或者象下面这样更具有 Unicode 意识:
TCHAR * p = _T("This is a test")

LPTSTR p = _T("This is a test");
你可以使用下面任意一种写法:
CString s = "This is a test"; // 8-bit only
CString s = _T("This is a test"); // Unicode-aware
CString s("This is a test"); // 8-bit only
CString s(_T("This is a test")); // Unicode-aware
CString s = p;
CString s(p);

用这些方法可以轻松将常量字符串或指针转换成 CString。

比如char*pStr = "adfadfadsfasdf";
CString strMsg(pStr);
就相当于转换了.

_T(char*)

char *a[256];
CString str;
str.format("%s",a);
就可以了,str就保存了a的值了.

直接赋植