title: Error in free(): invalid size
body: <pre><code>#include &lt;bits/stdc++.h&gt;
  
  using namespace std;
  
  class student
  {
   string name;
   string reg;
  public:
   void getdata()
   {
    getline(cin,name);
    getline(cin,reg);
   }
   void printdata()
   {
    cout&lt;&lt;name&lt;&lt;"\t"&lt;&lt;reg&lt;&lt;endl;
   }
  };
  
  int main()
  {
   ifstream fin;
   ofstream fout;
   student obj;
   fout.open("google.txt",ios::out|ios::binary);
   obj.getdata();
   fout.write((char*)&amp;obj,sizeof(obj));
   fout.close();
   student obj2;
   fin.open("google.txt",ios::in|ios::binary);
   fin.read((char*)&amp;obj2,sizeof(obj2));
   obj2.printdata();
   fin.close();
   return 0;
  }
  </code></pre>
  
  <p>I am trying a basic read and write operation of file handling of objects.
  But after executing the above code I am successfully able to write and read but I get an error message <code>*** Error in ./io: free(): invalid size: 0x00007ffea93f64b0 ***Aborted (core dumped)</code></p>
  
  <p>Input:
  Fire Blade
  , 17HFi394
  Output:<br>
  Fire Blade , 17HFi394
  and an error message : <code>*** Error in ./io: free(): invalid size: 0x00007ffea93f64b0 ***Aborted (core dumped)</code>
  Can anyone explain this error and what should I do to overcome this problem.</p>