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 }~報(bào)錯(cuò):2.cpp:9: error: cannot convert `std::string*' to `char*' for argument `1' to `char* strcpy(char*, const char*)'看不懂。問題2。如何定義string型數(shù)組指針啊。。。這程序我是想這樣做1 #include <iostream>2 #include <string>3 using namespace std;4 int main()5 {6 7 string *sr[3]={"ddf","bcd"};//報(bào)錯(cuò)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 }~
4 回答

月關(guān)寶盒
TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊
- 4 回答
- 0 關(guān)注
- 1489 瀏覽
添加回答
舉報(bào)
0/150
提交
取消