Source Code File 13-03_sonofpad

13-03_sonofpad.c

#include <ncurses.h>

int main()
{
    WINDOW *pop,*son;
    int x;

    initscr();

    /* create a new pad */
    pop = newpad(50,50);
    if( pop==NULL )
    {
        endwin();
        puts("Unable to create pad");
        return(1);
    }

    /* fill the pad */
    for(x=0;x<50;x++)
        waddstr(pop,"Hello ");

    /* create the subpad */
    son = subpad(pop,10,10,0,0);
    if( son==NULL)
    {
        endwin();
        puts("Unable to create subpad");
        return(1);
    }

    addstr("Press Enter to update");
    refresh();
    getch();

    prefresh(son,0,0,5,5,15,15);
    getch();

    endwin();
    return(0);
}

Output Screenshot

Notes

* The main pad, pop, never appears on the standard screen. Only the subpad, son, shows up.