| 1 |
'\" t |
| 2 |
.\" Copyright 1995, James R. Van Zandt <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH getw 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
getw, putw \- input and output of words (ints) |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <stdio.h> |
| 16 |
.P |
| 17 |
.BI "int getw(FILE *" stream ); |
| 18 |
.BI "int putw(int " w ", FILE *" stream ); |
| 19 |
.fi |
| 20 |
.P |
| 21 |
.RS -4 |
| 22 |
Feature Test Macro Requirements for glibc (see |
| 23 |
.BR feature_test_macros (7)): |
| 24 |
.RE |
| 25 |
.P |
| 26 |
.BR getw (), |
| 27 |
.BR putw (): |
| 28 |
.nf |
| 29 |
Since glibc 2.3.3: |
| 30 |
_XOPEN_SOURCE && ! (_POSIX_C_SOURCE >= 200112L) |
| 31 |
|| /* glibc >= 2.19: */ _DEFAULT_SOURCE |
| 32 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 33 |
Before glibc 2.3.3: |
| 34 |
_SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE |
| 35 |
.fi |
| 36 |
.SH DESCRIPTION |
| 37 |
.BR getw () |
| 38 |
reads a word (that is, an |
| 39 |
.IR int ) |
| 40 |
from |
| 41 |
.IR stream . |
| 42 |
It's provided for compatibility with SVr4. |
| 43 |
We recommend you use |
| 44 |
.BR fread (3) |
| 45 |
instead. |
| 46 |
.P |
| 47 |
.BR putw () |
| 48 |
writes the word |
| 49 |
.I w |
| 50 |
(that is, |
| 51 |
an |
| 52 |
.IR int ) |
| 53 |
to |
| 54 |
.IR stream . |
| 55 |
It is provided for compatibility with SVr4, but we recommend you use |
| 56 |
.BR fwrite (3) |
| 57 |
instead. |
| 58 |
.SH RETURN VALUE |
| 59 |
Normally, |
| 60 |
.BR getw () |
| 61 |
returns the word read, and |
| 62 |
.BR putw () |
| 63 |
returns 0. |
| 64 |
On error, they return |
| 65 |
.BR EOF . |
| 66 |
.SH ATTRIBUTES |
| 67 |
For an explanation of the terms used in this section, see |
| 68 |
.BR attributes (7). |
| 69 |
.TS |
| 70 |
allbox; |
| 71 |
lbx lb lb |
| 72 |
l l l. |
| 73 |
Interface Attribute Value |
| 74 |
T{ |
| 75 |
.na |
| 76 |
.nh |
| 77 |
.BR getw (), |
| 78 |
.BR putw () |
| 79 |
T} Thread safety MT-Safe |
| 80 |
.TE |
| 81 |
.SH STANDARDS |
| 82 |
None. |
| 83 |
.SH HISTORY |
| 84 |
SVr4, SUSv2. |
| 85 |
.SH BUGS |
| 86 |
The value returned on error is also a legitimate data value. |
| 87 |
.BR ferror (3) |
| 88 |
can be used to distinguish between the two cases. |
| 89 |
.SH SEE ALSO |
| 90 |
.BR ferror (3), |
| 91 |
.BR fread (3), |
| 92 |
.BR fwrite (3), |
| 93 |
.BR getc (3), |
| 94 |
.BR putc (3) |