get a character from stdin
#include <stdio.h> int fgetchar( void );
The fgetchar() function is equivalent to fgetc() with the argument stdin.
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 the function returns EOF. If a read error occurs, the error indicator is set, and the function returns EOF.
When an error occurs, the global variable errno contains a value indicating the type of error that has been detected.
#include <stdio.h> void main() { FILE *fp; int c; fp = freopen( "file", "r", stdin ); if( fp != NULL ) { while( (c = fgetchar()) != EOF ) fputchar(c); fclose( fp ); } }
WATCOM
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
errno, fgetc(), fgets(), fopen(), getc(), getchar(), gets(), ungetc()