title: Copying Structure's Object to a File stream, Writing it in a different Object
body: <p>I'm copying an object's data to a File Stream and then, from the same file stream, I'm writing that data to another object, but it fails. If I create another file stream and then i do the same process, it works.</p>
  
  <p>The Non-Working Code</p>
  
  <pre><code>struct customer
  {
      char name[23];
      float balance;
  };
  
  main()
  {
      customer savac,s;
      strcpy(savac.name,"Tina Marshall");
      savac.balance=213123; 
      fstream fout("text.txt",ios::in|ios::out|ios::binary);
      fout.write((char*)&amp;savac,sizeof(customer));
      fout.read((char*)&amp;s,sizeof(customer));
      cout&lt;&lt;s.name;
      cout&lt;&lt;"\n"&lt;&lt;s.balance;
  }
  </code></pre>
  
  <p>The Working Code</p>
  
  <pre><code>struct customer
  {
      char name[23];
      float balance;
  };
  
  main()
  {
      customer savac,s;
      strcpy(savac.name,"Tina Marshall");
      savac.balance=213123;
      fstream fout("text.txt",ios::in|ios::out|ios::binary);
      fout.write((char*)&amp;savac,sizeof(customer));
      fstream fin("text.txt");
      fin.read((char*)&amp;s,sizeof(customer));
      cout&lt;&lt;s.name;
      cout&lt;&lt;"\n"&lt;&lt;s.balance;
  }
  </code></pre>