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>fgetc() read a character from a stream</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fgetc()                 Read a Character from a Stream

 #include   <stdio.h>

 int        fgetc(stream);
 FILE       *stream;                     Pointer to FILE structure


    fgetc() reads a character from 'stream' as an unsigned int converted
    to an int at the current position. The file pointer is incremented to
    point to the next character.

    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:    fgetc(stdin) is the equivalent of fgetchar().

                fgetc() is similar to getc(), but getc() is a macro,
                while fgetc() is a function.

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

    The following statements open an existing file and print out its
    contents.

           #include <stdio.h>

           FILE *in;
           int next_ch;

           main()
           {
                if ((in = fopen("alpha.bet","r+"))!= NULL) {
                    while(!feof(in)) {
                        next_ch = fgetc(in);
                        printf("%c",next_ch);
                    }
                    fclose(in);
                 }
           }



See Also: fgetchar() getc() getchar() fputc()

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