如果我打开一个新文件进行输入,并且我input >> listSize;
在 while 循环之外调用然后继续调用input >> anothervariable
,它会自动在文件中前进还是会再次读取第一行?
例子:
input >> listSize;
BaseStudent* studentlist = new BaseStudent[listSize.atoi()];
while (!input.eof())
{
input >> anothervariable; // I want this to start on the second line, not the first
}
输入文件如下所示,我们可以对模式进行编码(忽略多余的空行):
12
Bunny, Bugs
Math 90 86 80 95 100 99 96 93
Schmuckatelli, Joe
History 88 75 90
Dipwart, Marvin
English 95 76 72 88
Crack Corn, Jimmy
Math 44 58 23 76 50 59 77 68
Kirk, James T.
English 40 100 68 88
Lewinsky, Monica
History 60 72 78
Nixon, Richard
English 35 99 70 70
Lincoln, Abraham
History 59 71 75
Clinton, William
Math 43 55 25 76 50 58 65
Duck, Donald
English 34 100 65 65
Duck, Daffy
History 55 70 70
Bush, George
Math 44 54 29 75 50 55 60