Conio.h
Encyclopedia
conio.h is a C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 header file used in old MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

 compilers to create text user interface
Text user interface
TUI short for: Text User Interface or Textual User Interface , is a retronym that was coined sometime after the invention of graphical user interfaces, to distinguish them from text-based user interfaces...

s. It is not described in The C Programming Language book
The C Programming Language (book)
The C Programming Language is a well-known programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as co-designed the Unix operating system with which development of the language was closely intertwined...

, and it is not part of the C standard library
C standard library
The C Standard Library is the standard library for the programming language C, as specified in the ANSI C standard.. It was developed at the same time as the C POSIX library, which is basically a superset of it...

, ISO C nor is it defined by POSIX
POSIX
POSIX , an acronym for "Portable Operating System Interface", is a family of standards specified by the IEEE for maintaining compatibility between operating systems...

.

This header declares several useful library functions for performing "console input and output" from a program. Most C compilers that target DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

, Windows 3.x
Windows 3.x
Windows 3.x can refer to either an individual or all of the following versions of Microsoft Windows:*Windows 3.0*Windows 3.1x*Windows 3.2...

, Phar Lap
Phar Lap (company)
Phar Lap was a software company specializing in software development tools for DOS operating systems. They were most noted for their software allowing developers to access memory beyond the 640 KiB limit of DOS and were an author of the VCPI standard.Phar Lap Software, Inc. was founded in April...

, DOSX, OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...

, or Win32 have this header and supply the associated library functions in the default C library. Most C compilers that target UNIX
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 and Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 do not have this header and do not supply the library functions. Some embedded systems are using a conio-compatible library .

The library functions declared by conio.h vary somewhat from compiler to compiler. As originally implemented in Lattice C
Lattice C
Lattice C was the first C compiler for MS-DOS on the IBM PC, in 1982. It was ported to many other platforms, such as mainframes , minicomputers , workstations , OS/2, the Commodore Amiga, Atari ST and the Sinclair QL.The compiler was subsequently repackaged by Microsoft under a distribution...

, the various functions mapped directly to the first few DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

 int 21h functions. But the library supplied with Borland
Borland
Borland Software Corporation is a software company first headquartered in Scotts Valley, California, Cupertino, California and finally Austin, Texas. It is now a Micro Focus subsidiary. It was founded in 1983 by Niels Jensen, Ole Henriksen, Mogens Glad and Philippe Kahn.-The 1980s:...

's Turbo C
Turbo C
Turbo C is an Integrated Development Environment and compiler for the C programming language from Borland. First introduced in 1987, it was noted for its integrated development environment, small size, extremely fast compile speed, comprehensive manuals and low price.In May 1990, Borland replaced...

 did not use the DOS API but instead accessed video RAM directly for output and used BIOS interrupt call
BIOS interrupt call
BIOS interrupt calls are a facility that DOS programs and some other software, such as boot loaders, use to invoke the facilities of the Basic Input/Output System...

s; they also have additional functions inspired on the successful Turbo Pascal
Turbo Pascal
Turbo Pascal is a software development system that includes a compiler and an integrated development environment for the Pascal programming language running on CP/M, CP/M-86, and DOS, developed by Borland under Philippe Kahn's leadership...

 library.

Compilers that targeted non-DOS operating systems, such as Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

, Win32 and OS/2, provided different implementations of these functions. The version done by DJ Delorie
DJ Delorie
DJ Delorie is an American software developer. He initiated and maintains the DJGPP project, a port of the GNU C/C++ compiler and tools suite, targeted for PCs running MS-DOS or DOS terminals under Microsoft Windows....

 for the GO32
DJGPP
DJGPP is a development suite for 386+ IBM PC compatibles which supports DOS-enabled operating systems. It is guided by DJ Delorie, who began the project in 1989. It is a port of the popular GCC compiler, as well as mostly GNU utilities such as bash, find, tar, ls, awk, sed, and ld to DPMI...

 extender is particularly extensive. 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.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK