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


putw - put a word on a stream (LEGACY)


#include <stdio.h>

int putw(int w, FILE *stream);


The putw() function writes the word (that is, type int) w to the output stream (at the position at which the file offset, if defined, is pointing). The size of a word is the size of a type int and varies from machine to machine. The putw() function neither assumes nor causes special alignment in the file.

The st_ctime and st_mtime fields of the file will be marked for update between the successful execution of putw() and the next successful completion of a call to fflush() or fclose() on the same stream or a call to exit() or abort().

This interface need not be reentrant.


Upon successful completion, putw() returns 0. Otherwise, a non-zero value is returned, the error indicators for the stream are set, and errno is set to indicate the error.


Refer to fputc().




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.

The putw() 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 output functions instead.




fopen(), fwrite(), getw(), <stdio.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 ]