The following is excerpted from the beginning Linux programming book
Compile-time plus-lncurses option
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <curses.h>
int main ()
{
int i;
INITSCR ();
if (!has_colors ())
{
Endwin ();
fprintf (stderr, "error-no color support on this terminal\n");
Exit (1);
}
if (Start_color ()!= OK)
{
Endwin ();
fprintf (stderr, "Error-could not initialize colors\n");
Exit (2);
}
Clear ();
MVPRINTW (5,5, "There are%d Colors,and%d color_pairs available", colors,color_pairs);
Refresh ();
Init_pair (1,color_red,color_black);
Init_pair (2,color_red,color_green);
Init_pair (3,color_green,color_red);
for (I=1;i<=3;++i)
{
Attroff (A_bold);
Attrset (Color_pair (i));
MVPRINTW (5+i,5, "color pair%d", i);
Attrset (Color_pair (i) | A_bold);
MVPRINTW (5+i,25, "bold color pair%d", i);
Refresh ();
Sleep (1);
}
Endwin ();
Exit (0);
}