你好,我是一个C++新手,我想知道下面的代码有什么问题。
int MAX = 15;
while (!inputfile.eof()){
getline(inputfile, name);
cout << name << endl;
for (int i = 0; i < MAX; i ++){
inputfile >> questionnumber >> answer;
cout << questionnumber << " " << answer << "\n";
}
//inputfile.ignore(); #This will ignore the Enter key in Buffer zone
//inputfile.sync(); #But how come this can't clean the Enter key in Buffer zone?
}
输入文件中的数据是
key
2 B
13 D
3 C
5 D
14 C
6 C
8 A
15 B
9 A
1 A
7 B
10 B
11 C
4 D
12 D
0 James
对不起,我的英语不好,不知道怎么描述这种问题。
谢谢。