void main()
{
//字符串转字符数组
string name = "ddddd";
char buf[] = {0};
strcpy(buf , name.c_str());//字符串转字符数组,使用strcpy
cout << name.c_str() << endl;//name.c_str()将字符串转换成字符数组
cout << buf << endl;
//字符数组转字符串
char buf1[]= "xxxxxx";
string name1;
name1 = buf1;
cout << name1 << endl;
}
标签:字符,c++,strcpy,数组,字符串,buf
From: https://www.cnblogs.com/wang-xiao-shuai/p/16981854.html