Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fopen(3s)

fread(3s)

gets(3s)

putc(3s)

scanf(3s)

ungetc(3s)

getc(3s)

Name

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

Syntax

#include <stdio.h>

int getc(stream)
FILE *stream;

int getchar()

int fgetc(stream)
FILE *stream;

int getw(stream)
FILE *stream;

Description

The getc function returns the next character from the named input stream.

The getchar function is identical to getc (stdin).

The fgetc function behaves like getc, but is a genuine function, not a macro. It may be used to save object text.

The getw function returns the next word (in a 32-bit integer on a VAX-11 or MIPS machine) 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() should be used to check the success of getw. The getw assumes no special alignment in the file.

Restrictions

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

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.

See Also

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

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