title: Assertion Error During Running the program
body: <p>I made a program in Visual Studio 2008 using C++ language and MFC Files. It is a graphical user interface which store student records in a file using file handling of C++. It  is working properly and shows or adds records but when I try to modify and delete records it will give a assertion error to me while running. </p>
  
  <p>Please help me out. </p>
  
  <p>Functions code that I use for modify and delete records are here.</p>
  
  <pre><code>void modifyrec()
  {
      Invalidate();
  
      bool found;
  
      struct student e;
  
      getname_dialog diag;
      if(diag.DoModal()==IDOK)
      {
          found = false;
  
          fp.SeekToBegin();
  
          while(fp.Read(&amp;e,sizeof(e))&gt;=sizeof(e))
          {
              if(e.batch_no==g_batchno &amp;&amp; strcmp(e.name,g_name)==0)
              {
                  found = true;
                  break;
              }
          }
  
          if(found == true )
          {
              modify_dialog mdiag(e);
              mdiag.DoModal();
          }
          else
              MessageBox("Record Not Found","Modify Record....");
      }
  }
  
  void delrec()
  {
      bool foun;
      struct student e;
  
      Invalidate();
  
      getname_dialog diag;
      if(diag.DoModal()==IDOK)
      {
          found = false;
          fp.SeekToBegin();
  
          CFile ft("temp.dat",CFile::modeCreate | CFile:modeWrite);
          while(fp.Read(&amp;e,sizeof(e))&gt;= sizeof(e))
          {
              if(e.batch_no==g_batchno &amp;&amp; strcmp(e.name,g_name)==0)
              {
                  found = true;
                  break;
              }
          }
  
          if(found == true )
          {
              modify_dialog mdiag(e);
              mdiag.DoModal();
          }
          else
              MessageBox("Record Not Found","Delete Record....");
  
  
          fp.Close();
          ft.Close();
  
          CFile::Remove("students.dat");
          CFile::Rename("temp.dat","student.dat");
          fp.Open("students.dat",CFile::modeCreate |CFile::modeNoTruncate |CFile::modeReadWrite);
      }
  }
  </code></pre>