putw() — Put a machine word on a stream

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2

both  

Format

#define _XOPEN_SOURCE
#include <stdio.h>

int putw(int w, FILE *stream);

General description

The putw() function writes the word w to the output stream (at the position at which the file offset, if defined, is pointing). The size of the 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 call to fflush() or fclose() on the same stream or a call to exit() or abort().

Note:

This function is kept for historical reasons. It was part of the Legacy Feature in Single UNIX Specification, Version 2, but has been withdrawn and is not supported as part of Single UNIX Specification, Version 3. New applications should use character-based output functions to replace putw() for portability.

If it is necessary to continue using this function in an application written for Single UNIX Specification, Version 3, define the feature test macro _UNIX03_WITHDRAWN before including any standard system headers. The macro exposes all interfaces and symbols removed in Single UNIX Specification, Version 3.

Returned value

If successful, putw() returns 0.

If unsuccessful, putw() returns a nonzero value, sets the error indicators for stream, and sets errno to indicate the error. Refer to fread() — Read items for errno values.

Related information