man(1) Manual page archive


     GETC(3S)                                                 GETC(3S)

     NAME
          getc, getchar, fgetc, getw, putc, putchar, fputc, putw  -
          character- or word-at-a-time stream input/output

     SYNOPSIS
          #include <stdio.h>        int putc(c, stream)
                                          char c;
          int getc(stream)                FILE *stream;
          FILE *stream;
                                          putchar(c)
          int getchar()
                                          putw(w, stream)
          int getw(stream)                FILE *stream;
          FILE *stream;
                                          fputc(c, stream)
          int fgetc(stream)               FILE *stream;
          FILE *stream;
    DESCRIPTION
         Getc returns the next character from the named input stream.

         Getchar() is identical to getc(stdin).

         Getw returns the next word (32-bit integer on a VAX) from
         the named input stream. Getw assumes no special alignment in
         the file.

         Putc appends the character c to the named output stream. It
         returns the character written.

         Putchar(c) is identical to putc(c, stdout).

         Putw appends word (i.e. int) w to the output stream. It
         returns the word written.  Putw neither assumes nor causes
         special alignment in the file.

         Fgetc and fputc behave like getc and putc, but are genuine
         functions, not  macros; they may be used to save object
         text.

         The standard output stream stdout is normally buffered, but
         is flushed whenever getc causes a buffer to be refilled from
         stdin.  The standard error stream stderr is normally
         unbuffered.  These defaults may be changed by setbuf(3).
         When an output stream is unbuffered, information appears on
         the destination file or terminal as soon as written.  When
         an output stream is buffered, many characters are saved up
         and written as a block.  Fflush may be used to force the
         block out early; see fopen(3).

    GETC(3S)                                                 GETC(3S)

    SEE ALSO
         fopen(3), ungetc(3), stdio(3)

    DIAGNOSTICS
         These functions return the integer constant EOF at end of
         file or error.  For getw or putw this indication is ambigu-
         ous; ferror(3) may be used to distinguish.

    BUGS
         Because they are implemented as macros, getc and putc treat
         stream arguments with side effects incorrectly.  For exam-
         ple, getc(*f++) is wrong.
         The routines in printf(3) provide temporary buffering even
         when buffering has been turned off.
         Write errors may be delayed until a subsequent stdio (3)
         writing, seeking, or file-closing call.