Hi there. I want to save the inventory in a txt file. Am using structures . When the user chooses to save in the menu i want to write the whole inventory to a txt file.
my structure looks like this
The function witch is supposed to save the invenoty looks like this
This doesn't show any errors but when i open the txt file it shows
int save(inventory book, int total)
fp.open("books.txt", ios::in | ios::out );
fp.write((unsigned char *)&book, sizeof(inventory));
some garbage characters. Also the read() command doesnt work.
Am using the write() comand correctly?
If please someone can show me an example of write(), and read()
with structures it would really help me.
attached the whole code if enyone wants to look at it. (book inventory program witch i just added the save function to test)
Thanx for your help.