Name: Anonymous 2017-10-10 23:14
Hey, /prog/.
I'm a C programmer trying to learn sepples.
Can anybody tell me what is happening in this code?
Why does it go into infinite loop mode if I give a non-integer and how to defend against this?
I'm a C programmer trying to learn sepples.
Can anybody tell me what is happening in this code?
Why does it go into infinite loop mode if I give a non-integer and how to defend against this?
#include<iostream>
using namespace::std;
int main(){
while(true){
//Why does this sperg out if I put a bad integer in?
int answer = -1;
cin >> answer;
cout << answer << "\n";
}
}