MFC 与 C++ 类型转换
C++ 中到的类型转换很多,先记录下来,多了写成一个类
1、CString转int
1 CString cNum="9527"; 2 int iNum = 0; 3 iNum=atoi(LPCTSTR(cNum));
2、int转CString
1 int iNum = 2211; 2 CString strNum = ""; 3 strNum.Format("%d", iNum);
3、string转CString
1 string str = "hello"; 2 CString cstr = ""; 3 cstr = str.c_str();
4、CString转string
1 CString cstr = "hello"; 2 string str = ""; 3 str = cstr.GetBuffer(0); 4 cstr.ReleaseBuffer();