Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>fgetchar() read a character from stdin</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fgetchar()              Read a Character from Stdin

 #include   <stdio.h>

 int        fgetchar(void);

    fgetchar() reads a single character from 'stdin'.


    Returns:    The character read.  On error or at end-of-file, EOF is
                returned.  Because EOF can be interpreted either as a
                legitimate end-of-file character or as an error
                indicator, use feof() or ferror() to verify which of
                these conditions is indicated by EOF.

      Notes:    fgetchar() is equivalent to fgetc(stdin).

                fgetchar() is similar to getchar(), but getchar() is a
                macro, while fgetchar() is a function.

 Portability:   Applies to MS DOS only.

   -------------------------------- Example ---------------------------------

    The following statements read characters from 'stdin' until a new
    line is reached.

           #include <stdio.h>

           char buff[100];
           int i, c, x;

           main()
           {
               i = 0;
               while ((c = fgetchar()) != '\n')
                   buff[i++] = c;
               buff[i++] = '\0';
               for (x = 0; x < i; x++)
                   printf("%c",buff[x]);
           }



See Also: fgetc() getchar() getc() fputchar() fputc()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson