libtermgraph logo

Overview | Download | Assignments/Screenshots | Documentation

libtermgraph is a simple, portable library for writing C and C++ programs that use a terminal window to display character-based graphics.  It was designed as a basis for projects in introductory programming courses; the idea is to extend the concept of line-by-line text output (printf, cout) to arbitrary placement of text on the screen.

The library exposes the following API:

void cons_clear_screen(void);
void cons_move_cursor(int row, int col);
void cons_change_color(int fg_color, int bg_color);
int cons_get_screen_height(void);
int cons_get_screen_width(void);
int cons_get_keypress(void);
void cons_sleep_ms(int ms);
void cons_printw(const char *fmt, ...);
void cons_update(void);

Internally, these functions are implemented using the Win32 Console API (on WIndows) or ncurses (on Unix/Linux/Cygwin).

Click on the links at the top of the page to download libtermgraph, see example programming assignments and screenshots of programs (written by students) that use libtermgraph, and access documentation.

libtermgraph is free software distributed under the terms of the MIT License.

Comments to Logo