vendredi 24 mai 2019

How to fix the infinity loop in my code? I think it skips the second cin so it keeps looping

If i the input is not an int, it's going to give a infinite loop, i think it skips the second cin, but i don't know how to fix it.

cout << "Number of days : ";
int days;
cin >> days;
while(!cin){
    cout << "Invalid";
    cin >> days;
}

Aucun commentaire:

Enregistrer un commentaire