Hi, I'm having another problem, this time with "std::cin". Maybe I don't know how it really works out, but I got a problem with emptying the function's buffer or whatever. So basically, I have this code, that checks for if any key is pressed at X moment, then I wait until none of the keyboard keys are down. Right after that I use cin to catch some data...
So the problem with this, but in fact, it's more of an annoyance, is that what I expect to happen doesn't happen. By this I mean that I suppose that "cin" shouldn't be receiving data when it is called, because previously I made sure that "Wait()" would wait for all keys to be released. But to my misunderstanding, when cin is finally called (when I have released "A"...), there's an "A" displayed in the console, and I think it shouldn't be there, as I wasn't pressing any key while cin was called...Code://Wait until no key is being down... void Wait() { for (;;) { bool Waiting = true; for (UCHAR i = 0; i < 255; i++) { if (GetAsyncKeyState(i)) { Waiting = false; break; } } if (Waiting) return; } } //Just wait until the "Key" gets pressed... void Wait_For_Key(UCHAR Key) { for (;;) { if (GetAsyncKeyState(Key)) return; } } //here is the code, under main()... //Let's say it just wait until the user presses "A"... Wait_For_Key(65); //Now wait until all keys, even "A", are released... Wait(); //Affect something to a variable... std::cin >> some_var;
I tried to call cin.clear() but it doesn't work on that... Do you understand?