c++ CSTring TO string
2014-06-25 20:21
260 查看
1.<pre id="answer-content-788564172" accuse="aContent" class="answer-text mb-10" style="margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace; white-space: pre-wrap; word-wrap: break-word; color: rgb(51, 51, 51); font-size: 14px; line-height: 24px; background-color: rgb(255, 255, 255);">string 是 语言的东西 是c++语言的 CString 是VC++ IDE内嵌的,是MFC的 不是一个概念 CString 离开VC++不能用 string 在任何支持C++的IDE中都能用
bool CMysqlHandle::CStringToString(CString &myCSting,string &mystring) { mystring.clear(); CStringA stra(myCSting.GetBuffer(0)); myCSting.ReleaseBuffer(); mystring = stra.GetBuffer(0); stra.ReleaseBuffer(); return true; }
2.
wstring是宽char,Unicode编码,一般情况下一个字符占两个字节大小 string是窄char,AscII编码,一个字符占一个字节大小
bool CMysqlHandle::StringToWString(string &str,wstring &wstr) { int nLen = (int)str.length(); wstr.resize(nLen,L' '); int nResult = MultiByteToWideChar(CP_ACP,0,(LPCSTR)str.c_str(),nLen,(LPWSTR)wstr.c_str(),nLen); if (nResult == 0) { return FALSE; } return TRUE; }
3.Cstring 转lpctstr
直接转即可
CString strTemp;
CFile tf(strTemp, CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary);
相关文章推荐
- C++: Converting an MFC CString to a std::string
- CFStringRef to cstring in c++
- The Complete Guide to C++ Strings, Part II - String Wrapper Classes
- [转]The Complete Guide to C++ Strings, Part II - String Wrapper Classes
- How to use libcurl in C++ with std::string
- How to get random string using C++ - 用 C++ 如何获取随机字符串
- C++之char*,char[],string,CString,数字等互相转化
- The Complete Guide to C++ Strings, Part II - String Wrapper Classes
- MFC/C++/C中字符类型CString, int, string, char*之间的转换
- C++ int,char,string,CString类型转换 [转]
- C++实现CString和string的互相转换
- Enum to String and vice versa in C++
- C++ convert int to string
- C++实现CString和string的互相转换
- C++ int,char,string,CString类型转换 [转]
- c++中的一些类型转换 : CString,string,int ,long,double,char*,const char*,date等
- c++ int to string
- 2005 C++中的CString 和String 转化
- c++ int to string(整型到字符串)
- C++ String: How to convert between 'CString' and 'std::string'?