ECE 103 Engineering Programming Chapter 57 Terminal Control Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material developed by Professor Phillip PSU ECE
Syllabus conio Library Extended Features curses Library
2 conio Library conio is a library that provides I/O functions for enhanced console access. Unbuffered keyboard input Direct screen output conio is not part of the C90 or C99 standard. conio availability depends on the compiler vendor. Microsoft Visual C/C++ → YES GNU GCC → NO (but can be added via extra code)
3 Basic conio function list (from Wikipedia): kbhit Determines if a keyboard key was pressed. getch Reads a character directly from the console without buffer and without echo. getche Reads a character directly from the console without buffer but with echo. ungetch Puts the character back into the keyboard buffer.
4 cgets Reads a string directly from the console. cscanf Reads formatted values directly from the console. putch Writes a character directly to the console. cputs Writes a string directly to the console. cprintf Formats values and writes them directly to the console.
5 Extended Features Some versions of conio also support: Setting the text cursor position Setting foreground and background text colors Clearing the text screen Availability depends on the compiler vendor. Microsoft Visual C/C++ → NO (but can be added) GNU GCC → NO (but can be added)
6 curses Library curses is a terminal control library originally designed for Unix-like systems. It is very comprehensive and supports text windows and keyboard/mouse control. Free implementations are available for: Microsoft Visual C (pdcurses) Cygwin+GCC (ncurses and pdcurses) Linux (ncurses) OS X (ncurses)