The getche() function is defined in the conio.h header file. It is a character input function which holds the output screen untill the user passes any key from the keyboard and also echo the pressed character using direct video or BIOS.
int getche(void);
The getche() function does not take any parameter.To store the input character in a program it has no any buffer area.
In getche() function the keyboard entered characters are returned as output.
Input | Return Value |
---|---|
if keypressed | pressed character |
#include <stdio.h>
#include <conio.h>
int main()
{
char value;
value = getche();
printf("Enter any character : \n");
printf("Entered character is : %c", value);
return 0;
}
Output:
Enter any character : x Entered character is : x
#include <stdio.h>
#include <conio.h>
int main()
{
char ch;
printf(“Press any character: ”);
ch = getche();
printf(“\nPressed character is: %c”, ch);
}
Output:
Press any character: a Pressed character is: a