title: Unable to write a data file,despite having no errors
body: <p>For my school project, i am creating a game. For save game features, I am using a <code>.DAT</code> binary file to read and write the data. When I enter the necessary details, the file doesn't have any data stored in it after exiting the program.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void save_game()
  {
      savegame sg;
  
      fstream x("savegame.dat", ios::out|ios::binary);
      char pn[25];
  
      sg.points = point;
  
      sg.lives = count;
  
      clrscr();
  
      settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);
  
      outtextxy(50, 50, "ENTER YOUR NAME,PLAYA!");
  
      cout &lt;&lt; "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
  
      gets(pn);
  
      strcpy(sg.pname, pn);
  
      x.write((char*)&amp;sg, sizeof(sg));
  
      quitgame();
  }
  </code></pre>
  
  <p>When I open the <code>.DAT</code> file, I expect to have some data stored in it. However, the file remains empty.</p>