Function Name: getch()
Function Header: <conio.h>
Declaration: int getch(void)
Return Value: This function returns the character read from the keyboard.
The getch() function is used to catch a character from the keyboard.
The getch() function reads a single character from the keyboard but does not show on the screen.
For this functionality, you can use the getch() function to hold the output window until hitting any key from the keyboard.
Example of the getch() function
#include <conio.h>
#include <stdio.h>
void main()
{
int c;
printf(“Press
any key\n”);
c = getch();
if (c)
printf(“A
key is pressed from keyboard ”);
else
printf(“An error occurred ”);
getch();
}
Output