std::string res = "中国";
char *result = new char[res.length() + 1];
for (int i = 0; i < res.length(); ++i)
{
result[i] = res[i]; //将string类型的res内容都放到result内
}
result[res.length()] = '\0'; //加上结束符
C++ 解决string转为char*中文乱码问题
最新推荐文章于 2024-05-03 21:03:24 发布