1

If I replace the getline for a cin, just as a test, it works as I want. But the moment I introduce the getline it creates a never-ending loop at the second iteration. I think it has something to be with the buffer but I don't know how it works so I need help.

This is the code:

while(true)
 {
      alumno++;
     cout<<"Alumno "<<alumno<<":"<<endl;
     getline(cin,nombre_alumno);
     if(nombre_alumno == "EXIT")break;

     cin>>nota;

 }

1 Answers1

0

After this statement

cin>>nota;

insert

std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

You will need to include the header

#include <limits>
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335