title: Debug error! Run-Time Check Failure #3
body: <p>I am getting this error when I run the program. It compiles successfully but gives me a few warnings about the uninitialized variables which, I thought are initialized. I get the error "Debug error! Run-Time Check Failure #3- The variable 'sumMaleGPA' is being used without being initialized."</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  void openFiles(ifstream&amp; inFile, ofstream&amp; outFile)
  {
  inFile.open("finalin.dat");
  outFile.open("finalout.dat");
  outFile &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2);
  inFile &gt;&gt; fixed &gt;&gt; showpoint &gt;&gt; setprecision(2);
  if (!inFile||!outFile)
  {
      cout &lt;&lt; "Problem opening file.";
  }
  }
  void initialize(int countFemale,int countMale,float sumFemaleGPA,float sumMaleGPA)
  {
  countFemale=0;
  countMale=0;
  sumFemaleGPA=0;
  sumMaleGPA=0;
  }
  void sumGrades(ifstream&amp; inFile, float sumFemaleGPA, float sumMaleGPA,int m,int f)
  {
  sumFemaleGPA=0;
  sumMaleGPA=0;
  
  if (!inFile)
      {
          inFile.open("finalin.dat");
      }
  char sex;
  float grade;    
  
  while(!inFile.eof())
  {
  
      inFile &gt;&gt; sex &gt;&gt; grade;
  
      switch (sex)
      {
      case 'f': (sumFemaleGPA= sumFemaleGPA + grade);
           f++;
          break;
      case 'm': (sumMaleGPA= sumMaleGPA + grade);
          m++; 
           break;
      }
  }
  }
  void averageGPA(float avgfGPA, float avgmGPA, int m, int f, float sumFemaleGPA, float sumMaleGPA)
  {
  avgmGPA=0;
  avgfGPA=0;
  
  avgfGPA=sumFemaleGPA/f;
  avgmGPA=sumMaleGPA/m;
  }
  
  void printResults(float avgfGPA, float avgmGPA, ofstream&amp; outFile)
  {
          cout &lt;&lt;"The average GPA of the female students is: "&lt;&lt;  avgfGPA &lt;&lt; endl;
          cout &lt;&lt;"The average GPA of the male students is: "&lt;&lt; avgmGPA;
  
          outFile &lt;&lt; "The average GPA of the female students is: "&lt;&lt;  avgfGPA  &lt;&lt; endl;
          outFile &lt;&lt;"The average GPA of the male students is: "&lt;&lt; avgmGPA;
  
  }
  
          int main()
  {
  
  int countFemale;
  int countMale;
  float sumFemaleGPA;
  float sumMaleGPA;
  float avgfGPA; 
  float avgmGPA;
  
  ifstream inFile;
  ofstream outFile;
  
  openFiles(inFile,outFile);
  initialize(countFemale,countMale,sumFemaleGPA,sumMaleGPA);
  sumGrades(inFile,sumFemaleGPA,sumMaleGPA,countMale,countFemale);
  averageGPA(avgfGPA,avgmGPA,countMale,countFemale,sumFemaleGPA,sumMaleGPA);
  printResults(avgfGPA,avgmGPA, outFile);
  
  
  }
  </code></pre>
  
  <p>Not sure where the error is happening so I posted the entire file.</p>