title: Why should we use cin.get(ch) after taking input using cin.getline() or cin?
body: <pre><code>#include&lt;fstream&gt;
  #include&lt;iostream&gt;
  using namespace std;
  
  int main(){
  ofstream fout("student.dat",ios::out);
  char name[20],ch;
  float marks=0.0;
  int i=0;
  
  for(i=0;i&lt;5;i++){
  cout&lt;&lt;"Student"&lt;&lt;(i+1)&lt;&lt;" :\tName  :";
  cin.get(name, 20);
  cout&lt;&lt;"\t\tMarks :";
  cin&gt;&gt;marks;
  cin.get(ch);    //Significance of this statement-1?
  fout&lt;&lt;name&lt;&lt;"\n"&lt;&lt;marks&lt;&lt;"\n";
  }
  fout.close();
  
  ifstream fin("student.dat",ios::in);
  cout&lt;&lt;"\n";
  for(i=0;i&lt;5;i++){
  fin.get(name,20);
  fin.get(ch);    //Significance of this statement-2?
  fin&gt;&gt;marks;
  fin.get(ch);    //Significance of this statement-3?
  cout&lt;&lt;"Student Name :"&lt;&lt;name;
  cout&lt;&lt;"\tMarks :"&lt;&lt;marks&lt;&lt;"\n";
  }
  fin.close();
  return(0);
  }
  </code></pre>
  
  <p><strong>INPUT-1:</strong> Program takes input completely and gives satisfactory output.</p>
  
  <p><strong>INPUT-2:</strong> Program takes input for only first record and gives output just after taking first input (<strong>When statement-1 is removed from program</strong>).</p>
  
  <pre><code> Student1 :      Name :Deepak     Marks :10
  </code></pre>
  
  <p><strong>OUTPUT-1:</strong> </p>
  
  <pre><code>Student Name :Deepak      Marks :10
  Student Name :Sandeep     Marks :20
  Student Name :Vipin       Marks :30 
  Student Name :Sachin      Marks :40
  Student Name :Ashish      Marks :50
  </code></pre>
  
  <p><strong>OUTPUT-2:</strong></p>
  
  <pre><code>Student Name :Deepak      Marks :10
  Student Name :    Marks :10
  Student Name :    Marks :10 
  Student Name :    Marks :10
  Student Name :    Marks :10
  </code></pre>
  
  <p>So now my question is:</p>
  
  <p><strong>1)</strong> Why program doesn't take full input in 2nd case?</p>
  
  <p><strong>2)</strong> Which is responsible for this behavior, cin.getline() or cin?</p>
  
  <p><strong>3)</strong> I have partial idea (still need some clear explaination) that cin.get(ch) is used to clear buffer, but which are other functions which behave in similar way?</p>