1 #include <iostream>2 #include <string>3 using namespace std;4 int main()5 {6 7 string sr[3]={"ddf","bcd"};8 string s[3];9 strcpy(s,sr);10 11 cout<<s[0]<<endl;12 13 return 0;14 }~报错:2.cpp:9: error: cannot convert `std::string*' to `char*' for argument `1' to `char* strcpy(char*, const char*)'看不懂。问题2。如何定义string型数组指针啊。。。这程序我是想这样做1 #include <iostream>2 #include <string>3 using namespace std;4 int main()5 {6 7 string *sr[3]={"ddf","bcd"};//报错8 string s[3];9 strcpy(s[0],*(sr));10 strcpy(s[1],*(sr+1));strcpy(s[2],*(sr+2));11 cout<<s[0]<<s[1]<<s[2]<<endl;12 13 return 0;14 }~
添加回答
举报
0/150
提交
取消