在网上看到很多总结的CString,string,char*转换,但是基本上是千遍一律,有些比较麻烦,根据自己的实践经历重新总结。
1. CString to string
CString cstr = "abc";
string str = cstr;
2.CString to char*
CString cstr = "abc";
char pc[100];
strcpy(pc,cstr);
3.string to CString
string str = "abc";
CString cstr = str;
4.string to char *
string str = "abc";
char *pc = str.c_str();
5. char * to string
char pc[100] = "abc";
string str = pc;
6. char * to CString
char pc[100] = "abc";
CString cstr = pc;