Is there anything like _getch()?
I want to get input as soon as the user taps the key, so this would make sense if I'm making a console snake game for example (there is no delimiter like "\n" for other istream inputs, as soon as I tap the key the snake must turn).
I don't know why _getch() isn't used but what's an alternative and why isn't _getch() itself good practice?
Also notice the following:
Code:
char foo;
while (true) {
foo = _getch();
cout << "taken\n";
}
Why do I see "taken" twice when I click a key? That's weird.. What is it reading the second time?
When I print foo, I get the key I pressed and follow by one single whitespace.. why is there a whitespace? And how do I make it so that it doesn't read the whitespace..
When we put foo to integer, we don't see 32 (ASCII for whitespace) being printed, but yet however when you typecast it then you get the whitespace.. Also the integer equivalent is in 4 digits..