getchar function will accept a character from the console or from a file, displays immediately while typing and we need to press Enter key for proceeding.
Syntax of getchar() is
It returns the unsigned char that they read.If end-of-file or an error is encountered getchar() functions return EOF.
The function “getchar()” reads a single character from the standard input device, the keyboard being assumed because that is the standard input device, and assigns it to the variable “a”.
C – GETCHAR() EXAMPLE PROGRAM :
printf(“Enter a character\n”);
printf(“Given character is %c \n”,a);
|Enter a character
Given character is C