這裏的bash(系統 - >的wget)命令是我的代碼:問題的在C++
string line;
ifstream toOpen;
toOpen.open("allfiles.txt", ios::in);
int fileCounter=0;
if(toOpen.is_open()){
while(!toOpen.eof()){
getline(toOpen,line);
string dl = "wget -q -E -O superman/" + href[0] + " " + line;
//cout << dl << endl;
fileCounter++;
system(dl);
}
toOpen.close();
}
凡allfiles.txt(內容):
http://www.xxx.com/index1.html
http://www.xxx.com/index2.html
凡HREF []值是像:{index1.html,index2.html,index3.html ...}
我的錯誤信息:
file.cpp:XX: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int system(const char*)’
你真的沒有遇到`std :: string :: c_str()`嗎? – 2010-11-25 17:43:16