How much data is there? What about structures and pointers to structures perhaps a binary tree or doubly linked list? Such things are already done in PASCAL its only a matter of syntax. CWSIV On Tue, 2004-01-06 at 11:30, Ged wrote:
Hi Davi,
I understand what you mean. however this also gives the same output file as before. My main problem is getting the data back into the program after I have exited and restarted. This is what I have been stuck with for the past few days. I'm beginning to think its not possible (although I know it is) as nobody, including experienced coders on c++ forums seems to be able to get it to work.
If you get a second, could you compile the code and run the program, you'll see what I mean.
Thanks,
Ged.
On Tuesday 06 January 2004 19:32, davicastro@terra.com.br wrote:
The main error is at:
void save_data(StockItem * tosave) .... fout.write((char *) &tosave, sizeof(tosave));
sizeof(tosave) is the same of sizeof(StockItem *), and probably 4 bytes. Furthermore, you should not use the & before tosave, since it is already a pointer (array). The same mistake occurs in the load code. If you want to store a C array you should also store its size (and also pass it as argument to others functions). If you want to fix this code, you should read some more about C pointers and arrays until everything get clear. Then it will be straightforward.
[]s Davi
-=SuSE Linux 9.0=-