Write a program to show the effect of getche()and getch().

#include<stdio.h>
#include<conio.h>
int main()
{
	printf("Enter any two alphabetic");
	getche();
	getch();
}

/*
Two characters are entered,the user can see only one character on the screen.The second character is
accepted but not console.
The getche() accepts and display the character where as getch() accept but not display the character.
Syntax of getche() is as follows:-
getche();*/

The program is designed to demonstrate the difference between the getche() and getch() functions in the conio.h library.

First, the program displays the message “Enter any two alphabetic”. Then, the getche() function is called to read and display a single character input from the user, which is visible on the screen. Next, the getch() function is called to read a single character input from the user, but this input is not displayed on the screen.

The difference between these two functions is that getche() reads a character and displays it on the screen, while getch() reads a character but does not display it. Both functions are commonly used in console-based programs to read user input without the need for the user to press the enter key.

Thanks

Write a program to show the effect of getche()and getch().

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top