Conio.h functions list in C
Introduction
Conio.h is a header file for the C programming language's Console Input and Output routines. This library offers tools for interacting with and modifying the input and output streams of the console. The majority of console-based programs that interface with the user only through input/output from the console window employ the routines described in Conio.h. In this article, we shall examine the Conio.h functions List in the C programming language.
Functions List
- clrscr(): The console screen can be cleared using the clrscr() method. Both its parameters and its output are null. The top left corner of the screen is where the pointer is placed after using this function to clear the console window.
Syntax:
clrscr();
- getch(): To retrieve a single character from the console without displaying it on the screen, we use the getch() method. It returns an integer value and requires no parameters. This method can be used to read user input without showing it in the console window.
Syntax:
char getch();
- kbhit(): To determine if a key on the keyboard has been depressed, use the kbhit() method. It returns an integer value and requires no parameters. It returns a non-zero value if a key has been depressed; otherwise, it returns zero.
Syntax:
int kbhit();
- putch(): To display a single character on the console window, use the putch() method. It just requires one character as an argument and produces nothing in return.
Syntax:
void putch(char ch);
- putstr(): A string is shown on the console window using the putstr() function. It accepts a string as input and produces no output.
Syntax:
void putstr(char *str);
- gotoxy(): The pointer can be moved to a specific location on the console window using the gotoxy() function. It accepts two inputs that are integer values, one for each row and column.
Syntax:
void gotoxy(int x, int y);
- textcolor(): The colour of the text in the console window is set using the textcolor() method. It accepts as an input an integer number that represents the colour code and outputs nothing.
Syntax:
void textcolor(int color);
- textbackground(): The backdrop colour of the console window is set using the textbackground() method. It accepts as an input an integer number that represents the colour code and outputs nothing.
Syntax:
void textbackground(int color);
- cprintf(): Formatted output is printed to the console window using the cprintf() function. It acknowledges a organize string as input at the side a adaptable list of parameters, and it outputs nothing. This work is comparable to printf(), but rather than printing yield to the standard yield stream, it does it on the support window.
Syntax:
void cprintf(char *format, ...);
- cscanf(): The formatted input from the console window is read using the cscanf() method. It acknowledges a arrange string as input beside a adaptable list of parameters, and it yields the number of things that were successfully examined. This strategy is comparable to scanf(), but rather than perusing information from the standard input stream, it peruses it from the comfort window.
Syntax:
int cscanf(char *format, ...);
- _getch(): The _getch() strategy from Microsoft Visual Studio could be a non-standard work that's comparable to the getch() work. Without putting the character on the screen, it is utilized to urge a single character from the support. It returns an numbers esteem and requires no parameters.
Syntax:
int _getch();
- _getche(): The _getche() function is a non-standard function offered by Microsoft Visual Studio, however it is comparable to the getche() method. A single character is obtained from the console and shown on the screen using this method. It returns an integer value and requires no parameters.
Syntax:
int _getche();
- _kbhit(): The _kbhit() function is a non-standard function offered by Microsoft Visual Studio, however it is comparable to the kbhit() method. It is utilised to determine if a keyboard key has been depressed. It returns an integer value and requires no parameters. It returns a non-zero value if a key has been depressed; otherwise, it returns zero.
Syntax:
int _kbhit();
- _putch(): Similar to putch(), the _putch() method is a non-standard function offered by Microsoft Visual Studio. On the console window, it is used to display a single character. It just requires one character as an argument and produces nothing in return.
Syntax:
void _putch(char ch);
- _cprintf(): The _cprintf() function from Microsoft Visual Studio is a non-standard function that is comparable to the cprintf() method. On the console window, formatted output is printed using this method. It accepts a format string as input along with a flexible list of parameters, and it outputs nothing.
Syntax:
void _cprintf(char *format, ...);
- _cscanf(): Although it is a non-standard function offered by Microsoft Visual Studio, the _cscanf() function is comparable to the cscanf() method. The console window's formatted input is read using this. It accepts a format string as input along with a flexible list of parameters, and it outputs the number of items that were successfully read.
Syntax:
int _cscanf(char *format, ...);
Usage of Conio.h Functions
Most commonly, basic console-based C programmes are written using the Conio.h routines. Input from the user can be obtained using these functions, output can be seen in the console window, the console screen can be cleared, the text and background colours can be changed, and the pointer can be moved to a specific location on the console window.
Conio.h routines are frequently used for developing text-based games or applications that include user interaction via the console window. Conio.h routines, for instance, can be used to gather input from the user and show the output on the console window in a programme that requests the user to provide their name and age before displaying a customised message.
Conio.h routines can also be used for debugging C programmes. Using Conio.h routines to provide diagnostic data on the console window might be beneficial when a C programme exhibits an error or unexpected behaviour. For example, a program that encounters a segmentation fault could use Conio.h functions to display the memory address where the fault occurred and the values of any relevant variables.
Conclusion
In conclusion, the Conio.h library offers a selection of functions that allow C programmers to communicate with the console and modify its input and output streams. Simple console-based programs may be written using these functions, and C programs can be debugged using them as well. Conio.h is not a standard library and is not available on all platforms, although it might be a helpful resource for Windows-based system developers.