fputwc(3)
๐ fputwc โ bestie edition ๐
okay so this is fputwc(3) from the Library Functions Manual (we're in the fputwc / putwc cinematic universe, get comfy ๐)
โจ NAME โจ
fputwc, putwc โ write a wide character to a FILE stream ๐
๐ LIBRARY ๐
Standard C library (libc, -lc) โ she's built in, no extra installs, we love that for us ๐
๐ธ SYNOPSIS ๐ธ
#include <stdio.h>
#include <wchar.h>
wint_t fputwc(wchar_t wc, FILE *stream);
wint_t putwc(wchar_t wc, FILE *stream);
๐ฆ DESCRIPTION ๐ฆ
So fputwc() is literally the wide-character equivalent of fputc(3), no cap. She writes the wide character wc to stream. That's the whole job. Main character energy fr fr.
Here's the vibe check on what she returns and when:
- If
ferror(stream)becomes true, she returnsWEOF๐ญ - If a wide-character conversion error happens, she sets
errnotoEILSEQand returnsWEOF๐ - Otherwise? She returns
wc. Iconic. We ate. โจ
Now putwc() โ the function or macro โ functions identically to fputwc(). But bestie, listen: it may be implemented as a macro, and it may evaluate its argument more than once ๐. And the manpage is very blunt about her: there is no reason ever to use it. periodt.
If you want the nonlocking counterparts, go see unlocked_stdio(3) ๐ง
๐ RETURN VALUE ๐
On success, fputwc() returns wc ๐ซถ. Otherwise, WEOF is returned, and errno is set to indicate the error. Not the glow-up we wanted but that's the deal ๐
๐ ERRORS ๐
Apart from the usual ones, there is:
EILSEQโ Conversion ofwcto the stream's encoding fails. She simply cannot do it, and she's telling you ๐
โญ ATTRIBUTES โญ
For an explanation of the terms used in this section, see attributes(7).
fputwc(),putwc()โ Thread safety:MT-Safe๐ฅ
(yes girl, she's thread safe, we stan a stable queen)
๐ STANDARDS ๐
C11, POSIX.1-2008.
๐ HISTORY ๐
C99, POSIX.1-2001. She's been around, she's established, she's legacy in the best way ๐ธ
๐ NOTES ๐
The behavior of fputwc() depends on the LC_CTYPE category of the current locale. Locale girlies, this one's for you ๐
In the absence of additional information passed to the fopen(3) call, it is reasonable to expect that fputwc() will actually write the multibyte sequence corresponding to the wide character wc. So like, expect bytes, get bytes, that tracks ๐
๐ SEE ALSO ๐
fgetwc(3), fputws(3), unlocked_stdio(3)
and that's the tea โ this whole page is straight from the Linux man-pages 6.20, dated 2026-02-08, and it's giving fputwc(3). love that for us, bye bestie ๐๐โจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms