If we have multiple cin statements and one of them gets a wrong input, every following cin fails. How to prevent that?
#include <iostream>
using namespace std;
int main() {
int a, b, c, d, e;
cin>>a;
cin>>b;
cin>>c;
cin>>d;
cin>>e;
return 0;
}
If I enter some string for first or any other variable that expects int, every cin that follows terminates. How to prevent this failure?
Aucun commentaire:
Enregistrer un commentaire