getc()                   Read a Character from a Stream (Macro)
 
 #include   <stdio.h>
 
 int        getc(stream);
 FILE       *stream;                     Pointer to file stream
 
    getc() is a macro that returns the next character from the input
    'stream'.  If there is an associated file pointer, it is incremented
    to point to the next character.
 
    Returns:    If successful, getc() returns the character read.  getc()
                returns the value of EOF if there is an error or
                end-of-file has been reached.
 
      Notes:    Use ferror() or feof() to determine whether an error or
                an end-of-file occurred.
 
                fgetc() is similar to getc(), but getc() is a macro,
                while fgetc() is a function.
 
  -------------------------------- Example ---------------------------------
 
    The following statements open and print a file.
 
          #include <stdio.h>
 
          FILE *in;
          int next_ch;
 
          main()
          {
               if ((in = fopen("alph.dat","r+")) != NULL) {
                  while(!feof(in))  {
                     next_ch = getc(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