Menu
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

C stdio getchar() Function

❮ C stdio Library


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.

❮ C stdio Library