std::putwchar(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 std::putwchar(3) β€” C++ Standard Libary energy 🌸

okay so real talk, bestie, you're reading the std::putwchar(3) page, and yes β€” the manual section literally says "C++ Standard Libary" up there in the header. not a typo I made, that's just how it's spelled, and honestly? we respect the chaos. πŸ’…

✨ NAME ✨

std::putwchar β€” it's literally std::putwchar, that's the whole name, we're not doing a whole dramatic subtitle here πŸŽ€

✨ SYNOPSIS ✨

okay so first up, it lives right here:

Defined in header <cwchar>

and the signature is exactly this, no cap:

std::wint_t putwchar( wchar_t ch );
Writes a wide character ch to stdout.

that's it. that's the function. one wide char, straight to stdout, main character behavior ✨

✨ PARAMETERS ✨

  • ch β€” the wide character you want to be written. that's it. that's the whole parameter. give her the char, she does the thing πŸ¦‹

✨ RETURN VALUE ✨

  • ch on success πŸŽ‰ (she returns the very character you fed her, iconique)
  • WEOF on failure 😭

✨ EXAMPLE ✨

// Run this code β€” go off, copy it, run it, live your truth:

#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'βˆ€',
        L'\n'
        })
        if (std::putwchar(ch) == WEOF)
        {
            std::puts("I/O error in std::putwchar");
            return EXIT_FAILURE;
        }

    return EXIT_SUCCESS;
}
lowkey notice how the loop bails out the second std::putwchar(ch) == WEOF hits β€” then it prints I/O error in std::putwchar with std::puts and returns EXIT_FAILURE. if everything slays, you get EXIT_SUCCESS. periodt πŸ’–

✨ POSSIBLE OUTPUT ✨

βˆ€βˆ€

that's right, two of them β€” one from the L'\u2200' and one from the L'βˆ€', and the L'\n' did a little invisible goodbye at the end 🌈

✨ SEE ALSO ✨

  • putchar β€” writes a character to stdout. (function) πŸ‘‘
  • fputwc β€” writes a wide character to a file stream. πŸ”₯
  • putwc β€” (function) bestie, she's right there πŸ’œ
  • C documentation for putwchar β€” the C side of the story 🧚

okay and before you go, sources & date check because we stan a documented page: this one's from http://cppreference.com, dated 2024.06.10, and it's the std::putwchar(3) page β€” now go write some wide characters, you absolute icon 🫢✨

πŸ“¦ where this page comes from