64,676
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string>
std::string TestStr()
{
std::string ret = "test";
return ret;
}
void main()
{
std::string teststr = TestStr();
const char* test = TestStr().c_str();
printf("1: %s\n", test); //输出 空 或 乱码
printf("2: %s\n", TestStr().c_str()); //输出 "test"
printf("3: %s\n", teststr.c_str()); //输出 "test"
system("pause");
}