std::fputwc(3)
π std::fputwc(3) π
okay so bestie, welcome to the C++ Standard Libary manual moment β yes, that's the manual name, and we're talking about std::fputwc(3). It's a little wide-character writer with main character energy, and the vibe check is: write one wide char to a stream, periodt. β¨
π NAME π
std::fputwc β std::fputwc. That's it. That's the name. No notes. π
π SYNOPSIS π
Defined in header <cwchar>:
std::wint_t fputwc( wchar_t ch, std::FILE* stream ); (1)
std::wint_t putwc( wchar_t ch, std::FILE* stream ); (2)
Writes a wide character ch to the given output stream stream.
Bestie, read the fine print:(2)may be implemented as a macro and may evaluatestreammore than once. That's not a drill, that's literally what the page says π«Ά.
π¦ PARAMETERS π¦
chβ wide character to be written. The little Unicode star of the show πstreamβ the output stream. The destination. The place wherechis headed.
π RETURN VALUE π
- Returns
chon success. Slay β - Returns
WEOFon failure. Sad girl hours π - If an encoding error occurs,
errnois set toEILSEQ.
π§ EXAMPLE π§
The original literally says // Run this code, so we're running it. Here's the example, verbatim, no edits, no crumb snatching:
// Run this code
#include <cerrno>
#include <clocale>
#include <cstdio>
#include <cstdlib>
#include <cwchar>
#include <initializer_list>
int main()
{
std::setlocale(LC_ALL, "en_US.utf8");
for (const wchar_t ch :
{
L'\u2200', // Unicode name: "FOR ALL"
L'\n',
L'β',
})
{
if (errno = 0; std::fputwc(ch, stdout) == WEOF)
{
std::puts(errno == EILSEQ
? "Encoding error in fputwc"
: "I/O error in fputwc"
);
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
π¦ POSSIBLE OUTPUT π¦
Possible output, exactly:
β
β
πΈ SEE ALSO πΈ
fputcβ writes a character to a file stream.putcβ (function).fputwsβ writes a wide string to a file stream (function).fgetwcβ gets a wide character from a file stream.getwcβ (function).- C documentation for
fputwc.
okay bestie, that's the whole page π
it's from the C++ Standard Libary manual, the source/version line is http://cppreference.com, and the date is 2024.06.10 β std::fputwc(3), signing off with a little sparkle π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms