4.3 curses - how to discard "premature" input?
Xinhua Wu
xwu at pollux.usc.edu
Tue Feb 14 09:56:13 AEST 1989
For the following program, how can I discard any premature input typed in
before the "Press any character: " prompt appears?
------------
#include <curses.h>
main()
{
int ch;
initscr();
crmode();
addstr("Press any character: ");
sleep(3);
refresh();
ch = getch();
printw("\n\n\nThe character entered was a '%c'.\n", ch);
refresh();
endwin();
}
-------------
"sleep(3)" is added just to illustrate the point. In practice, one often
has to wait for a menu to come up, etc. But during the waiting one might
inadvertently type something (or hit a return) which should be discarded.
Thanks in advance for any help/comments.
------
Xinhua Wu
xwu at cse.usc.edu
More information about the Comp.lang.c
mailing list