Reads a character from the standard input stream #include <stdio.h> int getchar( void ); The function call getchar( ) is equivalent to getc(stdin). Like getc( ), getchar( ) may be implemented as a macro. As it has no arguments, however, unforeseen side effects are unlikely. getchar( ) returns the character read. A return value of EOF indicates an error or an attempt to read past the end of the input stream. In these cases the function sets the error or end-of-file flag for stdin as appropriate. Examplechar file_name[256}; int answer; /* ... */ fprintf( stderr, "Are you sure you want to replace the file \"%s\"?\n", file_name ); answer = tolower( getchar( )); if ( answer != 'y' ) exit( -1 ); See Alsofgetc( ), fputc( ), getch( ), putc( ), putchar( ); the C99 functions to read and write wide characters: getwc( ), fgetwc( ), getwchar( ), putwc( ), fputwc( ), and putwchar( ), ungetc( ), ungetwc( ) |