1)TCHAR* 转string
TCHAR exePathAndName[MAX_PATH];
GetModuleFileName(NULL, exePathAndName, MAX_PATH);
(_tcsrchr(exePathAndName,'//'))[1]=0;
USES_CONVERSION;
string filepath = T2A(exePathAndName);
g_strDataDirecory = filepath + "data//";
2) CString转string
CString m_cstrInputStr = L"Hello";
USES_CONVERSION;
string parens = W2A(m_cstrInputStr.LockBuffer());
m_cstrInputStr.UnlockBuffer();
本文介绍如何将TCHAR*类型和CString类型的数据转换为string类型,包括使用_TCSRCHR函数截取路径和利用W2A函数进行转换的具体实现。
926

被折叠的 条评论
为什么被折叠?



