我有以下代码,我不知道如何将char字符串转换为std字符串。有人可以帮我吗?
char Path[STRING_MAX];
test->getValue(Config::CODE,Path);
size_t found;
cout << "Splitting: " << Path << endl;
found=Path.find_last_of("/");
cout << " folder: " << Path.substr(0,found) << endl;
cout << " file: " << Path.substr(found+1) << endl;
最佳答案
用这个:
std::string sPath(Path);
要么:
std::string sPath = Path;
要么:
std::string sPath;
sPath.assign(Path);
关于c++ - 如何将char字符串转换为std字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5556543/