Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getc(S) — Xenix 2.3.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ferror(S)

fopen(S)

fread(S)

gets(S)

putc(S)

scanf(S)



     GETC(S)                  XENIX System V                   GETC(S)



     Name
          getc, getchar, fgetc, getw - Gets character or word from a
          stream.

     Syntax
          #include <stdio.h>

          int getc (stream)
          FILE *stream;

          int getchar ()

          int fgetc (stream)
          FILE *stream;

          int getw (stream)
          FILE *stream;

     Description
          getc and getchar are macros.  getc returns the next
          character from the named input stream as an integer.  It
          also moves the file pointer, if defined, ahead one character
          in stream.  getchar() is identical to getc(stdin).

          fgetc behaves like getc, but is a genuine function, not a
          macro; it may therefore be used as an argument.  fgetc runs
          more slowly than getc, but takes less space per invocation.

          getw returns the next word from the named input stream.
          getw increments the associated file pointer, if defined, to
          point to the next word.  The size of a word is the same as
          an integer and varies from machine to machine.  getw assumes
          no special alignment in the file.

     See Also
          ferror(S), fopen(S), fread(S), gets(S), putc(S), scanf(S)

     Diagnostics
          These functions return the integer constant EOF at the end-
          of-file or upon a read error.  Because EOF is a valid
          integer, ferror(S) should be used to detect getw errors.

     Notes
          stream arguments with side effects are treated incorrectly
          because getc is implemented as a macro.  In particular,
          ``getc( *f++ )'' doesn't work properly.  fgetc should be
          used instead.

          Files written using putw(S) are machine-dependent and may
          not be read using getw on a different processor because of
          possible differences in word length and byte ordering.




     Page 1                                           (printed 8/7/87)





     GETC(S)                  XENIX System V                   GETC(S)



     Warning
          If the integer value returned by getc, getchar, or fgetc is
          stored into a character variable and then compared against
          the integer constant EOF, the comparison may never succeed
          because sign-extension of a character on widening to integer
          is machine-dependent.

















































     Page 2                                           (printed 8/7/87)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026