Source Code File 08-02_keywait1
08-02_keywait1.c
#include <ncurses.h>
int main()
{
int value = 0;
initscr();
addstr("Press any key to begin:\n");
refresh();
getch();
/* turn off getch() wait */
nodelay(stdscr,TRUE);
addstr("Press any key to stop the loop!\n");
while(getch() == ERR)
{
printw("%d\r",value++);
refresh();
}
endwin();
return 0;
}
Output Screenshot

Notes
* In this configuration, with nodelay() set, the getch() function returns ERR when a key is unavailable. Returning this constant doesn't indicate a problem, just that a key isn't waiting.
Copyright © 1997-2025 by QPBC.
All rights reserved
