echo '' ;

C Library – conio.h

The conio.h header file is a C library that provides functions for console input and output in the DOS and Windows environments. “Conio” stands for “console input/output”. This header file is not part of the standard C library and is specific to DOS and Windows systems.

Some commonly used functions declared in conio.h include:

  1. clrscr(): Clears the screen.
  2. getch(): Reads a character directly from the console without echoing it.
  3. getche(): Reads a character directly from the console and echoes it.
  4. cprintf(): Prints formatted output to the console.
  5. cscanf(): Reads formatted input from the console.

It’s important to note that conio.h is not standard and is not portable across different platforms or compilers. It was widely used in older DOS-based C programming, but it’s generally not recommended for modern development due to its lack of portability and non-standard nature. Most modern compilers, especially those targeting Unix-like systems, do not support conio.h. Instead, developers typically use standard input/output functions from stdio.h for console I/O.

getch()

The getch() function in conio.h reads a single character from keyboard. It doesn’t uses any buffer, so entered data is not displayed on the output screen.


getche()

  • The getche() function in conio.h reads a single character from keyword but data is displayed on the output screen. Press Alt+f5 to see the entered character.


clrscr

The clrscr() function is a part of the conio.h header file in C programming. It clears the contents of the screen in the console window. When called, it erases all text and graphics from the console window, leaving it empty.

Here’s a simple example demonstrating the usage of clrscr():

#include <stdio.h>
#include <conio.h>

int main() {
    printf("This text will be displayed on the screen.\n");
    getch(); // Wait for a key press
    clrscr(); // Clear the screen
    printf("After clearing the screen, this text will be displayed.\n");
    return 0;
}

In this example, printf() is used to print a message to the screen. Then, getch() is used to wait for a key press. After a key press, clrscr() is called to clear the screen, and then another message is printed using printf().

NEXT

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from ArunEworld

Subscribe now to keep reading and get access to the full archive.

Continue reading