getchar


getchar

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.

Example

 char 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 Also

fgetc( ), fputc( ), getch( ), putc( ), putchar( ); the C99 functions to read and write wide characters: getwc( ), fgetwc( ), getwchar( ), putwc( ), fputwc( ), and putwchar( ), ungetc( ), ungetwc( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net