![]() |
VOOZH | about |
The getchar() function in C is a standard library function used to read a single character from the standard input device (keyboard). It is commonly used for simple character-based input operations.
stdin). <stdio.h> header file.Enter a character: You entered: �
int getchar(void);
getchar() function does not take any parameters.
The following C programs demonstrate the use of getchar() function
Example 1: Read a single character using getchar() function.
Input
fOutput
The entered character is : fExample 2: Program to implement putchar to print the character entered by the user:
Input
Enter any random character between a-z: kOutput
The entered character is : kExample 3: Reading multiple characters using getchar()
Input
geeksforgeeksOutput
geeksforgeeksExample 4: Read sentences using getchar() function and do-while loop.
Input
Enter the characters
Welcome to GeeksforGeeksOutput
Entered characters are Welcome to GeeksforGeeks