Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getc(UCB) — UNIX 2BSD

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(3)

putc(3)

gets(3)

scanf(3)

fread(3)

ungetc(3)

GETC(UCB)  —  UNIX Programmer’s Manual

NAME

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

SYNOPSIS

#include <nstdio.h>

int getc(stream)
FILE *stream;

int getchar()

int peekc(stream)
FILE *stream;

int peekchar()

int fgetc(stream)
FILE *stream;

int getw(stream)
FILE *stream;

DESCRIPTION

Getc returns the next character from the named input stream.

Getchar() is identical to getc(stdin).

Peekc returns the next character from the named input, without advancing the pointer.  Note that it may cause the buffer to be filled and is inadvisable for pipes. 

Peekchar() is identical to peekc(stdin).

Fgetc behaves like getc, but is a genuine function, not a macro; it may be used to save object text. 

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

SEE ALSO

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

DIAGNOSTICS

These functions return the integer constant EOF at 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.

AUTHOR

Peekc was a product of the laboratory for computer science, M.I.T. 

BUGS

The end-of-file return from getchar is incompatible with that in UNIX editions 1-6. 

Because it is implemented as a macro, getc treats a stream argument with side effects incorrectly.  In particular, ‘getc(*f++);’ doesn’t work sensibly. 

7th Edition  —  4/8/79

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