The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


getw - get a word from a stream (LEGACY)


#include <stdio.h>

int getw(FILE *stream);


The getw() function reads the next word from the stream. The size of a word is the size of an int and may vary from machine to machine. The getw() function presumes no special alignment in the file.

The getw() function may mark the st_atime field of the file associated with stream for update. The st_atime field will be marked for update by the first successful execution of fgetc(), fgets(), fread(), getc(), getchar(), gets(), fscanf() or scanf() using stream that returns data not supplied by a prior call to ungetc().

This interface need not be reentrant.


Upon successful completion, getw() returns the next word from the input stream pointed to by stream. If the stream is at end-of-file, the end-of-file indicator for the stream is set and getw() returns EOF. If a read error occurs, the error indicator for the stream is set, getw() returns EOF and sets errno to indicate the error.


Refer to fgetc().




Because of possible differences in word length and byte ordering, files written using putw() are implementation-dependent, and possibly cannot be read using getw() by a different application or by the same application on a different processor.

Because the representation of EOF is a valid integer, applications wishing to check for errors should use ferror() and feof().

The getw() function is inherently byte stream-oriented and is not tenable in the context of either multibyte character streams or wide-character streams. Application programmers are recommended to use one of the character-based input functions instead.




feof(), ferror(), getc(), putw(), <stdio.h>, <utmpx.h>.


Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]