title: c++ skipping the if and for loops?
body: <p>I am writing a program that would accept a file from users and do some calculations based on the data in the file. The first line contains the right answers for a multiple answer test (with 6 questions). The second line contains student ID, the third line contains student answers, the fourth line contains a new student Id, followed by the answers, etc.</p>
  
  <p>I need to go through the file, choose the right answers and compare student answers to them. Then, for each student, display student ID, the number of rights, wrongs, and blanks (?) for each question.</p>
  
  <p>This is my code below and I am stuck because the program is skipping the loops and I do not know what to do?</p>
  
  <pre><code>#include &lt;iostream&gt;  // include to use cin and/or cout
  #include &lt;fstream&gt;   // include to use ifstream
  using namespace std;
  int main ()
  {
  int id, c, w, mis, s, numberL;
  string answer, a, correct;
  string info[numberL];
  char question [] = {'?'};
  cout &lt;&lt; " enter file " &lt;&lt; endl;
  cin &gt;&gt; a;
  ifstream myfile(a.c_str());
  myfile &gt;&gt; answer;  
  s = 0;
  while (s &lt;= numberL)
  {
    myfile &gt;&gt; info[s];
    s++;
  }
  for (int i =3; i &lt; numberL; i = i+2)
  {
    if ( numberL == answer[1])
    {
       c = c+1;
    }
    if ( numberL == question [1])
    {
       mis = mis+1;
    }     
    if ( numberL != answer [1] || numberL != question [1] )
    {
       w = w+1;
    }
  }
  printf("Student #    1    2    3   4   5   6  Mark    %\n");
  cout &lt;&lt; c &lt;&lt; endl;
  cout &lt;&lt; w &lt;&lt; endl;
  cout &lt;&lt; mis &lt;&lt; endl;
  cout &lt;&lt; answer ; 
  } 
  </code></pre>
  
  <p>The data in the .txt file is this:</p>
  
  <pre><code>AACBEE
  1093345
  BADBEE
  1234567
  ACCBEE
  8123345
  BAC?BE
  1234566
  A?B?EE
  </code></pre>