65,187
社区成员




#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");
}