Source Code File 11-05_clobber
11-05_clobber.c
#include <ncurses.h>
int main()
{
WINDOW *red,*blue;
int x;
initscr();
refresh();
/* colors */
start_color();
init_pair(1,COLOR_WHITE,COLOR_RED);
init_pair(2,COLOR_WHITE,COLOR_BLUE);
/* create windows */
red = newwin(10,24,5,10);
blue = newwin(10,24,5,40);
if( red==NULL || blue==NULL)
{
endwin();
puts("Unable to create windows");
return 1;
}
/* color and fill windows */
wbkgd(red,COLOR_PAIR(1));
wbkgd(blue,COLOR_PAIR(2));
for(x=0;x<34;x++)
{
waddstr(red,"red ");
waddstr(blue," blue");
}
wrefresh(red);
wrefresh(blue);
getch();
/* copy window */
copywin(red,blue,0,0,1,4,5,10,FALSE);
wrefresh(blue);
getch();
endwin();
return 0;
}
Output Screenshot

(Click image to see result.)
Notes
* The code is essentially identical to 11-04_copywin.c, with the change at Line 39 of TRUE to FALSE. The result, as seen in the output above, is that a given chunk of window blue is completely replaced with the contents of window red.
Copyright © 1997-2025 by QPBC.
All rights reserved
