MFC Unicode 字符集下格式转换

一.CString 和 char*

1.char*->CString

1     char* a = "fsafas";
2     CString str1=CString(a);
3     MessageBox(str1);
4 
5     CString str2;
6     str2 = a;
7     MessageBox(str2);    

2.CString->char*

1     CString str3 = TEXT("fasfa");
2     char* b;
3     USES_CONVERSION;
4     b = T2A(str3);

二.string和char*

1.string->char*

1     string str(“fsafsa”);
2     const char* c;
3     c = str.c_str();

2.char*->string

1 char *a="fasfsa";
2 string b=a;

三.CString和string

1.CString->string

1     USES_CONVERSION;
2     CString str4 = TEXT("fasfa");
3     string d;
4     d = T2A(str4);
5     

2.string->CString

1     string e = "fasfsa";
2     CString str5;
3     str5 = e.c_str();
4     MessageBox(str5);

 

你可能感兴趣的:(MFC Unicode 字符集下格式转换)