Ncurses

From Hackepedia
Revision as of 20:53, 8 March 2007 by Franks (talk | contribs) (New page: Ncurses stands for New Curses which is provided by the [http://www.gnu.org/software/ncurses/ GNU] team. It is the GUI between console and graphical to the point you use a mouse suc...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Ncurses stands for New Curses which is provided by the GNU team. It is the GUI between console and graphical to the point you use a mouse such as X or Windows. For the pedantic, I'm aware you can use a mouse in ncurses, such as software like gpm.

Let's try to make a Hello World program with ncurses. You will require gcc installed to try this, as well as an editor such as vi. Create a file called ncurses.c and enter the following into it:

#include <ncurses.h>
int main()
{	
initscr();			/* Start curses mode 		  */
printw("Hello World");	/* Print Hello World		  */
refresh();			/* Print it on to the real screen */
getch();			/* Wait for user input */
endwin();			/* End curses mode		  */
return 0;
}

once you save the file, let's compile it:

$ gcc -Wall -lncurses -o ncurses ncurses.c

-Wall will print all warnings, but you should have none. Now we will run our executable:

$ ./ncurses

You should see your screen completely get cleared (this was initscr()) and then it will print Hello World. For your next steps, check out the Manual at

$ man 3 ncurses