file processing, saving a structure

thank you
grey wolf and satm2008,

you are a great help, both of you enlightened me.

The codes you sent me were good but I had to make some adjustments.

I now have a problem with file processing, how to save a structure.
this is the code for my project. Anyone out there who can help will be much appreciated.
Here is an example of how to write a record to file:
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <fstream>

struct myStruct {
  char name[12];
  int age;
};

int main() {
  myStruct myRecord;
  fstream iofile("C:\\MYFILE.DAT", ios::binary | ios::out | ios::app);
  iofile.write((char*)&myRecord, sizeof(myStruct));
  iofile.close();
}
Topic archived. No new replies allowed.