Conio h c что это

от admin

Заголовочный файл conio.h

Что за заголовочный файл такой <conio.h>, и для чего он нужен? В K&R такой не описывают. Заранее спасибо.

<conio.h> содержит описание нестандартной библиотеки для работы с консолью ( clrscr , kbhit и тому подобное). Поставляется, ЕМНИП, со старыми Борландовскими компиляторами. Не пользуйтесь ей, если хотите, чтобы ваш код компилировался на более современных компиляторах.

Заметьте, что непосредственная работа с консолью противоречит философии юниксовских утилит, которые должны одинаково хорошо работать как с входными данными, полученными от пользователя, так и с выводом других программ. Поэтому правильная юниксовская утилита должна читать ввод из stdin и выводить его в stdout/stderr, позволяя эффективно использовать перенаправление потоков ввода-вывода.

Conio.h

conio.h (от англ. console input-output  — консольный ввод-вывод) — заголовочный файл, используемый в старых компиляторах, работающих в операционных системах MS-DOS, для создания текстового интерфейса пользователя. Тем не менее, он не является частью языка программирования Си, стандартной библиотеки языка Си, ISO C или требуемой стандартом POSIX.

Этот заголовочный файл объявляет несколько библиотечных функций для работы с «консольным вводом и выводом» программы. Большинство компиляторов языка Си, предназначенных для DOS, Windows 3.x, Phar Lap, DOSX, OS/2 или Win32 имели этот файл и обеспечивали сопутствующие библиотечные функции в библиотеке Си по умолчанию. Большинство компиляторов языка Си, предназначенных для UNIX и Linux, не имеют этого файла и не обеспечивают сопутствующих библиотечных функций.

Библиотечные функции, объявленные в conio.h, весьма различались в зависимости от компилятора. Первоначально реализованные в Microsoft Visual C++ различные функции привязывались напрямую к нескольким первым функциям DOS, связанным с прерыванием 21h. Но библиотека, поставляемая с Turbo C++ и Borland C++, не использует DOS API, а вместо этого напрямую обращается к видеопамяти для вывода информации и использования сигналов прерывания BIOS.

Компиляторы, предназначенные для операционных систем отличных от DOS, таких как Linux, Windows и OS/2, обеспечивали различные реализации этих функций.

Члены-функции

int kbhit(void) Определяет, было ли нажатие клавиш клавиатуры
int ungetch(int c) Помещает символ c обратно в буфер клавиатуры.
int getch(void) Считывает символ напрямую из консоли без использования буфера и echo-вывода.
int getche(void) Считывает символ напрямую из консоли без использования буфера, но с использованием echo-вывода.
int putch(int c) Функция _putch выводит символ c в консоль без буферизации. В случае успеха возвращает c. В противном случае возвращает EOF.
char *_cgets(char *buffer) Считывает строку из консоли и хранит ее в массиве, указывающим на буфер. buffer[0] , должен содержать максимальную длину (в символах) строки, то есть сколько символов нужно считать. Второй элемент массива buffer[1] указывает «где». _cgets хранит текущую длину строки. _cgets считывает символы до символа возврата, перевода строки или указанного максимума числа символов.
int _cprintf(const char *format, arg0. argn) Форматирование и вывод («печать») строки напрямую в консоль.
int _cputs(const char *string) Вывод строки напрямую в консоль.
int _cscanf(char *format, arg0. argn) Считывание и форматирование данных напрямую из консоли.

Смотри также

Ссылки

Wikimedia Foundation . 2010 .

Полезное

Смотреть что такое «Conio.h» в других словарях:

conio.h — Conio redirects here. For the profanity, see wikt:coño. 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,… … Wikipedia

Conio.h — is a header file used in old MS DOS compilers to create text user interfaces, however, it is not part of the C programming language, the C standard library, ISO C or required by POSIX.This header declares several useful library functions for… … Wikipedia

conio.h — (от англ. console input output  консольный ввод вывод)  заголовочный файл, используемый в старых компиляторах, работающих в операционных системах MS DOS, для создания текстового интерфейса пользователя. Тем не менее, он не является … Википедия

conio — Element prim de compunere savantă cu semnificaţia praf , în legătură cu praful , de (la) praf . [pron. ni o , var. coni . / < fr. conio , cf. gr. konis – praf]. Trimis de LauraGellner, 18.01.2005. Sursa: DN … Dicționar Român

Conio. — Conio. (v. gr. Konia, Staub), Staub … Pierer’s Universal-Lexikon

conio — / kɔnjo/ s.m. [lat. cŭneus ]. 1. a. [utensile per stampare monete o medaglie] ▶◀ punzone. ⇑ stampo. b. [operazione ed effetto del coniare, anche fig.] ▶◀ battitura, coniatura, coniazione. 2. (fig., spreg.) … Enciclopedia Italiana

conio — 1cò·nio s.m. CO 1a. stampo in acciaio a forma di punzone su cui vengono incisi disegni, figure o iscrizioni che si vogliono imprimere in rilievo su monete o medaglie; l impronta che ne risulta: riconoscere una moneta dal conio 1b. l operazione… … Dizionario italiano

conio — s. m. 1. punzone, torsello 2. (est.) impronta, stampo 3. cuneo, zeppa 4. coniazione, coniatura FRASEOLOGIA fior di conio, moneta che non ha mai circolato □ nu … Sinonimi e Contrari. Terza edizione

conio — <><><>s. m. 1 Operazione del coniare. 2 Pezzo di acciaio su cui è inciso il tipo che si vuole riprodurre sulla moneta o medaglia | Impronta fatta col conio | Fior di –c, di moneta che non ha mai circolato | Nuovo di –c, nuovissimo … Enciclopedia di italiano

Everything about conio.h library functions in C/C++

Whenever you write any C program, you must be using stdio.h and conio.h header files to your program. Have you wondered what these header files are required in your program?

There is a lot of information available about stdio.h header file and its functions on the internet but programmers often struggle to get information about the conio.h header file and its functions.

So in this article, you will find all the conio.h library functions, sample source code, and example of conio.h header file.
Let’s start with the overview.

conio.h C++ Library

What is conio.h in C/C++:

The conio stands for Console-Input-Output. The conio.h is a non-standard header file used in C and C++ programming. This file contains console input-output functions which are mostly used by MS-DOS compilers.

Читать:
Firefox как изменить кодировку страницы

Here we have explained some of the important and most widely used functions of conio.h header file. Click on each function to navigate through each function.

Note: Use Turbo C compiler to compile and execute conio.h header file functions.

Table of content:

  1. clrscr()
  2. getch()
  3. getche()
  4. putch()
  5. cgets()
  6. cputs()

7. cscanf()
8. cprintf()
9. kbhit()
10. textcolor()
11. textbackground()

conio.h header file functions:

clrscr():

Using this function you can clear the output command window. On the command prompt, we usually print code execution status, error information, and output results. During the code execution, if you want to clear the existing printed information on the output console then you can use clrscr() function.

Function Declaration:

void clrscr(void);

Example:

getch():

Use this function to read characters from the keyboard. This function is also used to hold the output screen until the user enters any character. If you don’t use this function then the output screen closes within a fraction of a second.

The getch() is a non-standard function provided by conio.h whereas getchar() is a standard c library function.

Function Declaration:

int getch(void);

Example:

getche():

This function is similar to getch() function. The only difference is that this function also prints the value entered by the user in the output window.

Function Declaration:

char getche();

Example:
Output:

putch():

Use this function to print information in the output window. This function prints only one character at a time on output window.

Function Declaration:
Example:
Output:

cgets():

Use this function to read a string of characters from the console. This function reads characters until it encounters carriage-return (CR) and linefeed (LF). The cgets() function replaces CR/LF with the null terminator (\0) at the end of the string.

Function Declaration:
Example:

cputs():

Use this function to print a string of characters on the output screen. The carriage-return and newline characters are not appended to the string. It does not convert newline character (\n) into combination of carriage – return (\r) and new-line character (\n).

Function Declaration:
Example:
Output:

cscanf():

The cscanf() function scans and reads input from the console. A format specifier is passed to cscanf() function to read input in the required format. This function returns EOF when it reached to end of the input stream.

Function Declaration:

Note: See the use of cscanf() function in the below example cprintf() function.

cprintf():

cprintf() function prints output values in the console as per format speficier.

Function Declaration:
Example:
Output:

kbhit():

Use this function to determine whether a key has been pressed or not. It returns a non-zero value when a key has been pressed otherwise returns zero.

Function Declaration:
Example:
Output:

textcolor():

Use this function to change the color of a text.

Function Declaration:
Example:
Output:

textbackground():

Use this function to change background color of the text.

Function Declaration:
Example:
Output:

How to include conio.h in your c program?

You can use the following syntax to include the conio header file in your program.

What is #include?

The term ‘include’ in C/C++ programming is a pre-processor directive which helps to import header files in your program. It also instructs the compiler to process these header files before compilation.

Name already in use

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Library <conio.h> For Linux

What is #include <conio.h>

If you see at the top of some C/C++ code, 90% of the time you’ll see the line #include <conio.h> .

We’re including the file <conio.h> into our main program. The <conio.h> header file contains certain library functions that peform input and output operation.

#include <conio.h> is a header file, conio stands for console-input-output and (.h) is basically header file extension.

It contains some functions and methods for formatting the output and getting input in the console.

conio h fatal error

The error will be shown like below :

List Function <conio.h>

Some of it’s functions which are often used :

  • kbhit — Determines if a keyboard key was pressed.
  • gcgets — 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.
  • getch — Get char entry from the console

How To Install Library #include <conio.h>

This is a library conio.h for linux. Just copy file and paste file conio.h on /usr/include/ but don’t forget before you want copy paste on /usr/include/ you must open folder as ADMINISTRATOR first !!

  • Open your terminal can as root
  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install git
  • git clone https://github.com/zoelabbb/conio.h.git or Click to Clone Repos
  • cd conio.h

Copy & Paste

  • sudo make install
  • Restart or Close your IDE and open it again
  • And done 😀

Now you can using library #include <conio.h> .

Wanna Support me ? You can buy me some coffee via :

About

This is a library conio.h for linux ��️ . you can install manual library conio.h for linux step by step here.

Related Posts