Jump to content

conio.h

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Brynet (talk | contribs) at 07:45, 7 November 2011 (This brings the function listing in line with other similar pages.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.


conio.h is a C header file used in old MS-DOS compilers to create text user interfaces. 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 required 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[1] 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 are using a conio-compatible library [2].

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. But 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; they also have additional functions inspired on the successful Turbo Pascal library.

Compilers that targeted non-DOS operating systems, such as Linux[citation needed], Win32 and OS/2, provided different implementations of these functions.[citation needed] The version done by DJ Delorie for the GO32 extender is particularly extensive[3]. Another example is SyncTERM's ciolib.

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 buffer.
  • 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.

Compilers provided later than 1989 have prepended an _ to the names, to comply with the requisites of the ANSI C Standard.

References

  1. ^ "Console and Port I/O in MSDN".
  2. ^ "MicroVGA conio Text User Interface Library".
  3. ^ "DJGPP C Library Reference - conio".