【发布时间】:2012-11-05 19:43:43
【问题描述】:
谁能帮我弄清楚是谁用 ifstream myfile(fileName); 在用 g++ 编译时产生错误?
string fileName;
cout << "\nPlease enter the name of your input file:" << endl;
cout << "->";
getline (cin, fileName);
cout << "fileName: " << fileName << endl;
string line;
ifstream myfile(fileName);
if (myfile.is_open()){
while(getline(myfile, line)){
cout << line << endl;
}
myfile.close();
} else {
cout << "Unable to open file";
}
【问题讨论】: