CString 和 string
CString ==> string
CstringstrData = TEXT("helloword");
Std::stringstr= (CStringA)
string == > CString
strData.Format(TEXT("%s"),str.c_str());
strData.Format(TEXT("%s"),str.data());
/*c_str()和data()区别是:前者返回带'/0'的字符串,后者则返回不带'/0'的字符串*/
CString 和 char*
CString ==> char*
1. CString s = TEXT("abcd");
char *p =(LPSTR)(LPCTSTR)s;
2. char szTemp[500];
CString strTemp = "123456789";
memset(szTemp,0,sizeof(szTemp));
sprintf(szTemp,"%s",strTemp);
char* ==> CString
1. char *p = "abcd";
CString s(p);
2. s.Format(TEXT("%s"),p);
string 转化为数字
string str ="1996";
1. 转化为int
std::stoi(str);
2. 转化为long
std::stol(str);
3. 转化为long long
std::stoll(str);
其他类型类似