请问如何把c++中的string类型转化为char*?
string str("hello world");
char gs[20];
strcpy(gs, str.c_str());
cout<<gs<<endl;
cout<<str.c_str()<<endl;
//string 中方法 c_str()返回const char *字符串
string str("hello world");
char gs[20];
strcpy(gs, str.c_str());
cout<<gs<<endl;
cout<<str.c_str()<<endl;
//string 中方法 c_str()返回const char *字符串