struct People
{
string name;
string birthday;
int scores[3];
};
int main()
{
/*
People student = { "xiao ming","1999/1/12" };
for (int i = 0; i < 3; ++i)
{
student.scores[i] = i + 88;
}
fstream file6;
file6.open("one_student_file.txt", ios::out | ios::binary);
file6.write((char*)(&student), sizeof(student));
file6.close();
//此段程序已经运行过了,已经建立了文件。
*/
fstream file7;
People s;
file7.open("one_student_file.txt", ios::in | ios::binary);
file7.read((char*)(&s), sizeof(s));
cout << s.name << endl;
file7.close();
/*
报错:
引发了异常: 读取访问权限冲突。
_Pnext 是 0x150F044。
*/
}
这是什么原因怎么修改?