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' at the current position. The
    file pointer is incremented to point to the next character.
 
    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:    The fgetchar() function is equivalent to fgetc(stdin).
 
                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);
               }
          }

Seealso:



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