getchar function(Read Character) in C Language – example and detail

In the C Programming Language, the getchar characteristic reads a character from the stdin stream.

Syntax

The syntax for the getchar function in the C Language is:

int getchar(void);

Returns

The getchar characteristic returns the personality read. If an error occurs, the getchar characteristic will set the stdin’s error indicator and return EOF. If the getchar feature encounters the cease of stream, it will set the stdin’s end-of-file indicator and return EOF.

Required Header

In the C Language, the required header for the getchar characteristic is:

#include <stdio.h>

Applies To

In the C Language, the getchar function can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the getchar function:

fgetc function <stdio.h>

getc function <stdio.h>

See Also

Other C features that are noteworthy when dealing with the getchar function:

fputc feature putc feature putchar feature ungetc feature