<$BlogRSDURL$>
when NULL isn't quite...
2004-03-16
  I'm starting this Blog to keep an account of projects I'm working on, and whatever other interesting things I learn!

Primary Language:
C/C++

Other Vested Interests, In No Particular Order:
Win32, MFC, ATL, OpenGL, Java

/*----- (0.o) -----*/
And to get things started:

When you're getting input from keyboard in C, scanf just doesn't cut it. It's *masked* and too specific in what it can take as input. Sometimes you just want the "any" key...so what to do? kbhit() is an amazingly useful function that requests the keyboard buffer for the next character hit (button hit). The inherent problem lies in that all the buttons will accumulate in the keyboard buffer. So here's a simple way of forcing a clear in the kbbuffer:

// Before your code to ask for the "any" key...
for( ; kbhit(); getch() )
/* Code that asks for "any" key.
Code that checks kbhit() and uses the input.
Use getch() to grab the char */



Thats all! Simple wasn't it?1? And now you know...

Until next time...stay frosty...

and dont' forget: NULL often isn't
...

ARCHIVES
03/14/2004 - 03/21/2004 / 03/21/2004 - 03/28/2004 /


Powered by Blogger