std::string path = "d:\a\b\" ;这是路径
wstring filename=L"h1";这是文件的名字
最终我想要的是d:\a\b\h1.txt 这个完整的路径
C++ 字符串的拼接的问题
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
小学狗喵喵叫 2020-03-31 14:25关注std::string WStringToString(const std::wstring &wstr) { std::string str; int nLen = (int)wstr.length(); str.resize(nLen, ' '); int nResult = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wstr.c_str(), nLen, (LPSTR)str.c_str(), nLen, NULL, NULL); if (nResult == 0) { return ""; } return str; } ............................................................... std::string path = "d:\\a\\b\\" ; wstring filename=L"h1"; path=path+WStringToString(filename)+".txt";解决 无用评论 打赏 举报