CString是MFC中的
标准C中没有string,有string.h头文件,其中是strcpy,strcmp等函数。但操作对象都是char*类型
string是C++中封装的
转化:LPCSTR char*
char*与string:
char *ch = str.c_str();
char* ch = str.data();
string s1 = ch;
string str = string(ch);
string str(ch);
char*与CString:
char* ch=cstr.getbuffer();
CString cStr1 = ch;
CString cStr2 = CString(ch);
CString cStr2(ch);
string与CString:
CString cstr(s1.c_str());
cstr2.Format("%s", s2.c_str());
cstr2.Format("%s", s3.data());
str=cstr3.GetBuffer(0);
str = LPCSTR(cstr);