[Previous] [Contents] [Next]

getw()

Get a word from a stream

Synopsis:

#include <stdio.h>

int getw( FILE* stream );

Library:

libc

Description:

The getw() function returns the next word (that is, integer) from the named input stream. This function 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. The getw() function assumes no special alignment in the file.

Returns:

The next word, or the constant EOF at the end-of-file or upon an error; it sets the EOF or error indicator of stream, respectively. Because EOF is a valid integer, ferror() should be used to detect getw() errors.

Errors:

EOVERFLOW
The file is a regular file and an attempt was made to read at or beyond the offset maximum associated with the corresponding stream.

Classification:

Legacy Unix

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

Caveats:

Because of possible differences in word length and byte ordering, files written using putw() are implementation-dependent, and might not be read correctly using getw() on a different processor.

See also:

fclose(), ferror(), fgetc(), flockfile(), fopen(), fread(), getc(), getc_unlocked(), getchar(), getchar_unlocked(), gets(), putc(), scanf(), ungetc(),


[Previous] [Contents] [Next]