conio.h is a C header file used mostly by MS-DOS compilers to provide console input/output. It is not described in The C Programming Language book, and it is not part of the C standard library, ISO C nor is it defined by POSIX.
This header declares several useful library functions for performing "console input and output" from a program. Most C compilers that target DOS, Windows 3.x, Phar Lap, DOSX, OS/2, or Win32 have this header and supply the associated library functions in the default C library. Most C compilers that target UNIX and Linux do not have this header and do not supply the library functions. Some embedded systems use a conio-compatible library.
The library functions declared by conio.h vary somewhat from compiler to compiler. As originally implemented in Lattice C, the various functions mapped directly to the first few DOS int 21h functions. The library supplied with Borland's Turbo C did not use the DOS API but instead accessed video RAM directly for output and used BIOS interrupt calls. This library also has additional functions inspired from the successful Turbo Pascal one.
Compilers that targeted non-DOS operating systems, such as Linux, Win32 and OS/2, provided different implementations of these functions. The version done by DJ Delorie for the GO32 extender is particularly extensive. Another example is SyncTERM's ciolib. It is common to include curses.h instead of conio.h, if a program is compiled on a non-DOS operating system.
- Member functions
- 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 c back into the keyboard buffers.
- 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.
- clrscr - Clears the screen.
Compilers provided later than 1989 have prepended an _ to the names, to comply with the requisites of the ANSI C Standard.
- Schildt, Herbert (1995). C: The Complete Reference (3rd ed.). Berkeley, Calif.: Osborne McGraw-Hill. p. 288. ISBN 0-07-882101-0. "For DOS-compatible compilers, the direct console I/O functions generally use the CONIO.H header file."
- "Console and Port I/O in MSDN".
- "MicroVGA conio Text User Interface Library".
- "DJGPP C Library Reference - conio".
- Digital Mars's documentation
- IO FAQ - explanation and suggestions for non-standard console IO
- Borland-style CONIO implementation for MinGW/Dev-C++
- List of ways to get raw keyboard input