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 returns WEOF ๐Ÿ˜ญ
  • If a wide-character conversion error happens, she sets errno to EILSEQ and returns WEOF ๐Ÿ’€
  • 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 of wc to 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