这是我试图使用的代码:
//Have the user input the file name that they want to read
cout << "Enter name of file: ";
cin >> recordName;
//Create the object that the file will be read into
ifstream records;
//Open file for reading
records.open(recordName);
文本文件只是人员姓名和工资率的列表。该代码不会按原样编译,我不知道为什么它不会将字符串读取为文本文件名。