Let's consider this code:
Code:
char foo;
cin >> foo;
cout << foo;
for (int i = 1; i <= 10; i++) {
foo = _getch();
cout << "\n" << (int)foo;
}
string bar;
cin >> bar;
cout << bar;
Suppose you entered "hello"
foo is reading h, and bar is reading ello.
_getch() is not reading from the stream at all!
But from what I saw Turbo C's getche() was reading from the stream because I had a getche() which detected for say a key "k", when the key is pressed it plays sound() for say 1 second. I noticed that if I kept pressing k when the sound is being played, then even if I stopped pressing k the program will continue to be play k because getche() was taking k from the stream from when I had been pressing k when the sound was being played.
Now I'm not sure if getche() returns 0 like _getch().
edit: I don't know why that makes a difference but I'm just hoping it does.. lol. So we can use the getche() to read from input buffer, but is there a way to read from the buffer while there is something in fact to read from the buffer?