1、char[] 转化 string
char buffer[20]="hello!";
string str(buffer);
cout<<str;
2、 string 转化char[]
string str="hello!";
char buffer[20]={0};
sprintf(buffer,"%s",str.c_str);
cout<<buffer;
1、char[] 转化 string
char buffer[20]="hello!";
string str(buffer);
cout<<str;
string str="hello!";
char buffer[20]={0};
sprintf(buffer,"%s",str.c_str);
cout<<buffer;