#include <iostream>
#include <string>
using namespace std;int main()
{
string str;
cin>>str;
char *text=new char[str.size()+1];
strcpy(text,str.c_str());
text[strlen(text)+1]='\0';
strcat(text,'\0');//不用上句用此句却运行时出错,为什么
system("pause");
return 0;
}
#include <string>
using namespace std;int main()
{
string str;
cin>>str;
char *text=new char[str.size()+1];
strcpy(text,str.c_str());
text[strlen(text)+1]='\0';
strcat(text,'\0');//不用上句用此句却运行时出错,为什么
system("pause");
return 0;
}
strcat(text,'\0');// “\n”