Source Code File 10-03_sub3
10-03_sub3.c
#include <ncurses.h> int main() { WINDOW *sub; initscr(); /* create subwindow on stdscr */ sub = derwin(stdscr,LINES-2,COLS-2,1,1); if( sub==NULL) { endwin(); puts("Unable to create subwindow"); return(1); } /* draw a box around stdscr */ box(stdscr,0,0); /* put text to the stdscr */ addstr("I'm writing text\n"); addstr("to the standard screen."); refresh(); getch(); wclear(sub); wrefresh(sub); getch(); endwin(); return(0); }
Output Screenshot
(Click to see results.)
Notes
* After pressing Enter (or any key), the subwindow's contents are erased. Above, the text o the standard screen. disappears. (Click the image to view.)
* This source code file is referenced as 10-03_sub2.c
in the book.
Copyright © 1997-2024 by QPBC.
All rights reserved