我试图学习C ++,也许有人可以帮助我。 当我从文件中读取一切都没问题,但程序告诉我这个:
*_Pnext != 0; *_Pnext = (*_Pnext)->_Mynextiter)
_Pnext was 0x6BD9AC.
也许有人知道问题是什么。谢谢!
Struct.h
struct Autos {
string model;
string year;
Autos *next_node;
};
int main(){
Autos car;
Autos carTemp;
Fill(car);
PrintAuto(car);
ofstream fout;// Write File
fout.open(path, fstream::out | fstream::binary);
fout.open(path,ostream::app); Добавляет данные
if (!fout.is_open()) {
cout << "There is no file there!" << endl;
}
else {
fout.write((char*)&car, sizeof(Autos));
}
fout.close();
ifstream fin;//Read file
fin.open(path, fstream::in ,fstream::binary);
if (!fin.is_open()) {
cout << "There is no file" << endl;
}
else {
fin.read((char*)&carTemp, sizeof(Autos));
PrintAuto(carTemp);
}
fin.close();
system("pause");
return 0;
}