MFC里面CString 与 string 互相转化 的问题。_基础类_VC/MFC-ITnose http://www.itnose.net/detail/6110703.html
2015-12-31 09:25
260 查看
MFC里面CString 与 string 互相转化 的问题。_基础类_VC/MFC-ITnose http://www.itnose.net/detail/6110703.html
大致是这样
CString-string:
CString str1;
m_editUsername.GetWindowTextW(str1);
char *chr1 = new char[str1.GetLength() + 1];
WideCharToMultiByte(CP_ACP, 0, str1.GetBuffer(), -1, chr1, str1.GetLength() + 1, NULL, NULL);
string tmp1 = chr1;
string-CStirng:
CString str;(注意:不能写成CString str=userID.c_str();)
str = userID.c_str();
AfxMessageBox(str);
大致是这样
CString-string:
CString str1;
m_editUsername.GetWindowTextW(str1);
char *chr1 = new char[str1.GetLength() + 1];
WideCharToMultiByte(CP_ACP, 0, str1.GetBuffer(), -1, chr1, str1.GetLength() + 1, NULL, NULL);
string tmp1 = chr1;
string-CStirng:
CString str;(注意:不能写成CString str=userID.c_str();)
str = userID.c_str();
AfxMessageBox(str);
相关文章推荐
- strong/weak/assign/copy/retain
- TurboMail邮件服务器邮件群发实用技巧
- Exception in thread "ContainerBackgroundProce
- 理解 retain 、copy 、NSMutableString 、NSString 的用法
- LeetCode Container With Most Water
- LeetCode: 008-Contains Duplicate
- UVa 10976 Fractions Again?!(分数拆分)
- ArcGIS Server:Service failed to start
- 2014 Multi-University Training Contest 1 - J Rating
- Brainiac Designer
- 书-Programming Game AI by Example
- glib g_main_loop理解
- AS开发AIDL程序(2)
- 使用AS开发AIDL程序(1)
- opencv_traincascade.exe用到的参数及解释
- Factorial Trailing Zeroes 阶乘的后边有几个0
- ld: library not found for -lPods clang: error: linker command failed with exit code 1 (use -v to see
- wait_event_interruptible 使用方法
- web.xml中<security-constraint>和四种认证类型
- Error Domain=NSURLErrorDomain Code=-999错误