fgetchar()               Read a Character from Stdin
 
 #include   <stdio.h>
 
 int        fgetchar(void);
 
    fgetchar() reads a single character from 'stdin'.
 
 
    Returns:    The character read.  EOF is returned on error or
                end-of-file. However, because EOF is a legitimate integer
                value that can be read by this function, feof() or
                ferror() should be used to verify an end-of-file or error
                condition.
 
      Notes:    fgetchar() is equivalent to fgetc(stdin).
 
                fgetchar() is similar to getchar(), but getchar() is a
                macro, while fgetchar() is a function.
 
  -------------------------------- Example ---------------------------------
 
    The following statements read characters from 'stdin' until a new
    line is reached.
 
         #include <stdio.h>
 
         char buff[100];
         int i, c;
 
         main()
         {
             i = 0;
             while ((c = fgetchar()) != '\n')
                   buff[i++] = c;
             buff[i++] = '\0';
             for (x = 0; x < i; x++)
                 printf("%c",buff[x]);
         }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster