title: using getline(cin, string) on a loop not working properly
body: <p>I am using a for loop to input data in a structure array, I am not able to get a string variable to have white spaces, such that the stored name is two or more words as opposed to one. Can anyone help me properly use <code>getline</code> in a loop? </p>
  
  <p>It works when I do not use a loop, not sure what is causing the error in this program though.</p>
  
  <p>Below is the sample that is giving me trouble:</p>
  
  <pre><code>void Data_Input(int numberOfStudents, int numberOfTests, classroom* &amp;student){
      for (int count = 0; count &lt; numberOfStudents; count++){
          cout &lt;&lt; "For student number " &lt;&lt; count + 1 &lt;&lt; 
                  ", please input the following data:";
          cout &lt;&lt; "Student Name: ";
          //cin &gt;&gt; student[count].Name; (this option does not allow white spaces)
          getline(cin, student[count].Name); // &lt;-- this line 
      }
  }
  </code></pre>