Reputation: 471
I have a block of code like the following :
char option;
while (1) {
option = -1;
option = getch();
if(option == 13){
//do something
}
else{
//do something
}
}
On the second loop, the else part auto triggers, even if I press enter(13), for some reason and hence I'm unable to understand why this is happening?
Upvotes: 2
Views: 653
Reputation: 11
Essencially the getch function only reads the first thing you press in your keyboard or already is in the buffer. So, if you try to type 13, the getch function will only read the '1'.
Upvotes: 1