Source Code File 08-09_flush
08-09_flush.c
#include <ncurses.h> int main() { char buffer[81]; initscr(); addstr("Type. I'll wait...\n"); refresh(); napms(5000); /* 5 seconds */ addstr("Flushing buffer.\n"); flushinp(); addstr("Here is what you typed:\n"); getnstr(buffer,80); endwin(); return(0); }
Output Screenshot
(Click to update image.)
Notes
* If you comment out Line 14, then whatever you type while the program naps appears on the screen. That text is stored in a buffer (not a stream), and it's fetched by the getnstr() statement at Line 16.
Copyright © 1997-2024 by QPBC.
All rights reserved