#include<iostream>
#include<string.h>
using namespace std;
int main()
{
string str1="AABB";
cout<<"str1:"<<str1<<endl;
char buf1[1024]={0};
strcpy(buf1,str1.c_str());
cout<<"buf1:"<<buf1<<endl;
return 0;
}
运行结果:
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
string str1="AABB";
cout<<"str1:"<<str1<<endl;
char buf1[1024]={0};
strcpy(buf1,str1.c_str());
cout<<"buf1:"<<buf1<<endl;
return 0;
}
运行结果: