[Previous]
[Contents]
[Next]

getchar()

get a character from stdin

Synopsis:

#include <stdio.h>
int getchar( void );

Description:

The getchar() function is equivalent to getc() with the argument stdin.

Returns:

The next character from the input stream pointed to by stdin. If the stream is at end-of-file, the end-of-file indicator is set, and getchar() returns EOF. If a read error occurs, errno is set, and getchar() returns EOF.

Examples:

#include <stdio.h>

void main()
  {
    FILE *fp;
    int c;

    fp = freopen( "file", "r", stdin );
    while( (c = getchar()) != EOF )
      putchar(c);
    fclose( fp );
  }

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

errno, fgetc(), fgetchar(), fgets(), fopen(), getc(), gets(), ungetc()


[Previous]
[Contents]
[Next]