std::fputws(3)
π std::fputws π
okay bestie, welcome to the std::fputws(3) page from the C++ Standard Libary β and yes, that's literally how the header spells βLibrary,β so weβre keeping it exactly as-is ππ
. This function is giving wide-character output but make it a whole vibe, and weβre gonna get into every single detail. No cap.
π NAME π
std::fputws β std::fputws. Thatβs it. Sheβs concise, sheβs iconic, she said βmy name is my nameβ πββοΈβ¨.
β¨ Synopsis β¨
Defined in header <cwchar>:
int fputws( const wchar_t* str, std::FILE* stream );
So hereβs the tea: std::fputws writes every wide character from the null-terminated wide string str to the output stream stream, as if by repeatedly executing std::fputwc. π«Ά
And the important little detail: the terminating null wide character from str is not written. Not me being dramatic, thatβs just the rule, bestie. π«
πΈ Parameters πΈ
strβ null-terminated wide string to be written.streamβ output stream.
π Return value π
- On success, returns a non-negative value π
- On failure, returns
EOFand sets the error indicator (seestd::ferror) onstreamπ
lowkey important: that failure case is not a vibe. Check the error indicator onstreamif you getEOF.
π§ Example π§
// Run this code
#include <clocale>
#include <cstdio>
#include <cwchar>
int main()
{
std::setlocale(LC_ALL, "en_US.utf8");
int rc = std::fputws(L"εΎ‘δΌγΏγͺγγ", stdout);
if (rc == EOF)
std::perror("fputws()"); // POSIX requires that errno is set
}
π Possible output π
εΎ‘δΌγΏγͺγγ
π See also π
fputsβ writes a character string to a file stream (function)wprintfβ prints formatted wide character output to stdout, a file stream or a bufferfwprintfβ (function)swprintffputwsβ writes a wide string to a file stream (function)fgetwsβ gets a wide string from a file stream (function)- C documentation for
fputws
xoxo, this std::fputws(3) page is from http://cppreference.com, version/date 2024.06.10 β bye bestie, go write some wide strings π
π«Άπ
π¦ 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