0
void fileRead()
{
    student s22;
    fstream out;
    out.open("ABC.txt",ios::in);
    while(!out.eof())
    {
        out.read((char *)&s22,sizeof(s22));
        cout<<s22.roll_no<<"\t"<<s22.name<<"\t\t"<<s22.marks<<"\t"<<endl;
    }
}

当我尝试使用C++ 中的读取函数从文件中读取数据时,它会返回最后一条记录 2 次。

Output like this:
11  Ram    70
12  Mohan  80
12  Mohan  80

我不明白这个问题。请帮我解决这个问题。

4

0 回答 0