C programming question about input...
I call several getch()''s durring my program and I was wondering how to stop the user from doing stuff before they can see it. Someone on a different site said something about using fflush to empty the stdin, but didn''t say exactly how and what I tried didn''t work. If there is another way to do this then go ahead and suggest it. Thanks in advance... (in regular c only)
"Practice means good, Perfect Practice means Perfect"
I don''t fully understand your question, but nevertheless I suggest you look at getche(), which echoes the character to the console. Also look at getc() and putc() in combination. One of them may fit your situation perfectly.
IIRC kbhit() should do the trick. I believe something along the lines of the following functions might work.
Edited by - Dactylos on September 23, 2001 2:04:10 AM
void flush_input_buffer(void){ // Read keys as long as there is still // a keypress in the input buffer while (kbhit()) getch();}; char get_new_char(void){ // remove all keypresses from the input buffer... flush_input_buffer(); // ...and wait for a new keypress return (char)getch();};
Edited by - Dactylos on September 23, 2001 2:04:10 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement