


      GETC(3S)                    (UNIX 5.0)                   GETC(3S)



      NAME
           getc, getchar, fgetc, getw - get character or word from
           stream

      SYNTAX
           #include <stdio.h>

           int getc (stream)
           FILE *stream;

           int getchar ()

           int fgetc (stream)
           FILE *stream;

           int getw (stream)
           FILE *stream;

      DESCRIPTION
           Getc returns the next character (i.e. byte) from the named
           input stream.  It also moves the file pointer, if defined,
           ahead one character in stream.  Getc is a macro and so
           cannot be used if a function is necessary; for example one
           cannot have a function pointer point to it.

           Getchar returns the next character from the standard input
           stream, stdin.  As in the case of getc, getchar is a macro.

           Fgetc performs the same function as getc, but is a genuine
           function.  Fgetc runs more slowly than getc, but takes less
           space per invocation.

           Getw returns the next word (i.e. integer) from the named
           input stream.  The size of a word varies from machine to
           machine.  It returns the constant EOF upon end-of-file or
           error, but as that is a valid integer value, feof and
           ferror(3S) should be used to check the success of getw.
           Getw increments the associated file pointer, if defined, to
           point to the next word.  Getw assumes no special alignment
           in the file.

      SEE ALSO
           fclose(3S), ferror(3S), fopen(3S), fread(3S), gets(3S),
           putc(3S), scanf(3S).

      DIAGNOSTICS
           These functions return the integer constant EOF at end-of-
           file or upon an error.

      BUGS
           Because it is implemented as a macro, getc treats
           incorrectly a stream argument with side effects.  In



      Page 1                                         (73 A2 02MTA REV1)






      GETC(3S)                    (UNIX 5.0)                   GETC(3S)



           particular, getc(*f++) doesn't work sensibly.  Fgetc should
           be used instead.
           Because of possible differences in word length and byte
           ordering, files written using putw are machine-dependent,
           and may not be read using getw on a different processor.


















































      Page 2                                         (73 A2 02MTA REV1)



