getchar

Equivalent to getc with the argument stdin (function or macro)

Local Servers:blocking
Remote Servers:blocking
Classification:ANSI
Platform:NLM
Service:Stream I/O

Syntax

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

Return Values

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

Remarks

The getchar function or macro is equivalent to getc with the argument stdin.

See Also

getc

getchar Example

  #include <stdio.h>  
   
  main ()  
  {  
     FILE    *fp;  
     int      c;  
     fp = freopen ("data.fil", "r", stdin);  
     while ( (c = getchar () ) != EOF)  
        putchar (c);  
     fclose (fp);  
  }