You must include the curses.h file at the beginning of any program that calls curses subroutines. To do this, use the following statement:
#include <curses.h>
Before you can call subroutines that manipulate windows or screens, you must call the initscr or newterm subroutine. These subroutines first save the terminal's settings. These subroutines then call the setupterm subroutine to establish a curses terminal.
Before exiting a curses program, you must call the endwin subroutine. The endwin subroutine restores tty modes, moves the cursor to the lower left corner of the screen, and resets the terminal into the proper nonvisual mode. You can also temporarily suspend curses. If you need to suspend curses, use a shell escape or system call for example. To resume after a temporary escape, you should call the wrefresh or doupdate subroutine. The isendwin subroutine is helpful if, for optimization reasons, you don't want to call the wrefresh subroutine needlessly. You can determine if the endwin subroutine was called without any subsequent calls to the wrefresh subroutine by using the isendwin subroutine.
Most interactive, screen-oriented programs require character-at-a-time input without echoing the result to the screen. To establish your program with character-at-a-time input, call the cbreak and noecho subroutines after calling the initscr subroutine. When accepting this type of input, programs should also call the following subroutines:
Curses Overview for Programming
Windows in the Curses Environment