char s1[] = "hello word";
cout << s1 << endl;
string s2 = s1; //char 转 string
cout << s2 << endl;
const char *s3 = s2.c_str();//string 转 const char
cout << s3 << endl;
char s4[100];
strcpy_s(s4, s3);// const char 转 char
cout << s4 << endl;
const char *s5 = s4;
cout << s5 << endl;//char 转 const char
C++ const char / char /string 的相互转换
最新推荐文章于 2023-02-18 21:47:15 发布