title: Store and Load objects from a file
body: <p>I'm making this program for class and we are supposed to store objects from a class in a file and then load them. But I always get the last object stored instead of the first. Tried the seekp function but it doesn't work. Also shouldn't the size of an object be 38 bytes, instead of the 48 i'm getting?</p>
  
  <pre><code>void student::load()
  {
  fstream fin;
  fin.open("StudentData.bin",ios::binary|ios::in);
  fin.read((char*)this,sizeof(*this));
  }
  void student::store(int z)
  {
  fstream fout;
  fout.open("StudentData.bin",ios::binary|ios::out);
  //fout.seekp(38*z, fout.beg)
  cout&lt;&lt;sizeof(*this); 
  fout.write((char*)this,sizeof(*this));
  }
  
  
  for(i=0;i&lt;count;i++)
  {
      s[i].store(i);
  }
  cout&lt;&lt;"Done!";
  student pleb;
  pleb.load();
  pleb.showstudent();
  return 0;
  </code></pre>
  
  <p>}</p>