跳到主要內容

C-style String & C++ String & CString

C-style string to C++ string C-style string to CString
char str[] = "Hello World";
string str = string(str);
char str[] = "Hello World";
CString cs = CString(str);

C++ string to C-style string CString to C-style string
string str = string("Hello World");
char *ptr = str.c_str();
CString str = CString("Hello World");
char *ptr = str.GetBuffer(str.GetLength());
str.ReleaseBuffer();

留言