C stdio getchar() Function
Example
Read three characters from user input:
char a, b, c;
a = getchar();
b = getchar();
c = getchar();
printf("%c %c %c", a, b, c);
Definition and Usage
The getchar() function reads one character of user input and returns its ASCII value.
The getchar() function is defined in the <stdio.h> header file.
Note: More accurately, it reads from the location specified by stdin which is usually keyboard input but it may be configured to point to a file or other location.
Syntax
getchar();
Technical Details
| Returns: | An int value representing the ASCII value of the character that was read. |
|---|