The problem is with my output when i save some data in the binary file of class supermarket with item being one of its global variable the output screen shows only the last saved object in the loop that to infinitely. i want the output to show all the objects stored in the binary file.
i have already tried to use object.read((char*)&item,sizeof(item))
in my while loop condition and also tried using !object
but the i never get the required output.
void show_items()
{
system("cls");
ifstream object("Items",ios::in|ios::binary);
while(!object.eof())
{
object.read((char*)&item,sizeof(item));
item.diplay();
system("pause");
}
object.close();
}
Aucun commentaire:
Enregistrer un commentaire