Conio.h

conio.h

conio.h

C header file


conio.h is a C header file used mostly by MS-DOS compilers to provide console input/output.[1] It is not part of the C standard library or ISO C, nor is it defined by POSIX.

This header declares several useful library functions for performing "istream input and output" from a program. Most C compilers that target DOS, Windows 3.x, Phar Lap, DOSX, OS/2, or Win32[2] 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 or cc65 use a conio-compatible library.[3]

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 target non-DOS operating systems, such as Linux or OS/2, provide similar solutions; the unix-related curses library is very common here. Another example is SyncTERM's ciolib. The version of conio.h done by DJ Delorie for the GO32 extender is particularly extensive.[4]

Functions

kbhitDetermines if a keyboard key was pressed as well
cgetsReads a string directly from the console
cscanfReads formatted values directly from the console
putchWrites a character directly to the console
cputsWrites a string directly to the console
cprintfFormats values and writes them directly to the console
clrscrClears the screen
getchGet char entry from the console
getcheGet char entry from the console with buffer

References

  1. 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.
  2. "DJGPP C Library Reference – conio". libc.a reference. Retrieved January 22, 2022.

Share this article:

This article uses material from the Wikipedia article Conio.h, and is written by contributors. Text is available under a CC BY-SA 4.0 International License; additional terms may apply. Images, videos and audio are available under their respective licenses.