Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fclose(3S)

ferror(3S)

fopen(3S)

fread(3S)

gets(3S)

putc(3S)

scanf(3S)

stdio(3S)

ungetc(3S)



GETC(3S-SVR4)       RISC/os Reference Manual        GETC(3S-SVR4)



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

SYNOPSIS
     #include <stdio.h>

     int getc (FILE *stream);

     int getchar (void);

     int fgetc (FILE *stream);

     int getw (FILE *stream);

DESCRIPTION
     getc returns the next character (i.e., byte) from the named
     input stream [see intro(3)] as an unsigned char converted to
     an int.  It also moves the file pointer, if defined, ahead
     one character in stream.  getchar is defined as getc(stdin).
     getc and getchar are macros.

     fgetc behaves like getc, but is a function rather than a
     macro.  fgetc runs more slowly than getc, but it takes less
     space per invocation and its name can be passed as an argu-
     ment to a function.

     getw returns the next word (i.e., integer) 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 size of an integer and varies from machine to
     machine.  getw assumes no special alignment in the file.

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

DIAGNOSTICS
     These functions return the constant EOF at end-of-file or
     upon an error and set the EOF or error indicator of stream,
     respectively.  Because EOF is a valid integer, ferror should
     be used to detect getw errors.

NOTES
     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 implementation dependent.

     The macro version of getc evaluates a stream argument more
     than once and may treat side effects incorrectly.  In



                        Printed 11/19/92                   Page 1





GETC(3S-SVR4)       RISC/os Reference Manual        GETC(3S-SVR4)



     particular, getc(*f++) does not work sensibly.  Use fgetc
     instead.

     Because of possible differences in word length and byte ord-
     ering, files written using putw are implementation depen-
     dent, and may not be read using getw on a different proces-
     sor.

     Functions exist for all the above-defined macros.  To get
     the function form, the macro name must be undefined (e.g.,
     #undef getc).












































 Page 2                 Printed 11/19/92



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