将一个班级学生的标记和滚动详细信息写入文件中。输出仅包含最后输入的数据。为什么会这样?
#include<fstream.h>
int main()
{
ofstream fout;
fout.open("File1",ios::out);
char cch;
fout<<"ROLLNO\t"<<"MARKS"<<"\n";
int rollno,marks;
do
{
cout<<"Enter the rollno1";
cin>>rollno;
cout<<"Enter the marks";
cin>>marks;
fout<<rollno<<"\t"<<marks<<"\n";
cout<<"Do you want to insert more?" ;
cin>>cch;
}
while(cch=='y');
fout.close();
ifstream fin;
char ch;
fin.open("File1",ios::in);
fin.seekg(0);
fin.tellg();
while(fin)
{
fin>>rollno;
fin>>marks;
cout<<rollno<<"\t"<<marks<<"\n";
}
fin.close();
return 0;
}
请帮我找到错误。