Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getc.bsd(3S) — Domain/IX SR9.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(3S)

putc(3S)

gets(3S)

scanf(3S)

fread(3S)

ungetc(3S)

GETC(3S)

NAME

getc, getchar, fgetc, getw − get character or word from stream

USAGE

#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 from the input stream.

Getchar() is identical to getc(stdin). 

The function fgetc operates like getc, and may be used to save object text. 

Getw returns the next 32-bit integer word from the input stream. It returns the constant EOF on end-of-file or error, but since that is a good integer value, feof and ferror(3S) should be used to check the success of getw.  Getw does not assume any special alignment in the file. 

NOTES

The EOF return from getchar is incompatible with that used in early versions (1-6) of the UNIX System. 

Because it is implemented as a macro, getc treats a stream argument with side effects incorrectly.  Specifically, “getc(*f++);” doesn’t work the way you might expect. 

DIAGNOSTICS

These functions return the integer constant EOF on end-of-file or upon read error.  A stop with message “Reading bad file” means an attempt has been made to read from a stream that has not been opened for reading by fopen(3S). 

RELATED INFORMATION

fopen(3S), putc(3S), gets(3S), scanf(3S), fread(3S), ungetc(3S)

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