谁能帮我找出谁是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";
}