std::putchar(3)
π std::putchar(3) π
okay so bestie, welcome to the std::putchar page from the C++ Standard Libary manual (yes, thatβs the manual name, weβre keeping it exactly as it is π
). This whole page is about writing one character to stdout, and honestly? iconic.
β¨ NAME β¨
std::putcharβstd::putchar, the tiny one-character writer with main character energy π
β¨ Synopsis β¨
Defined in header <cstdio>:
int putchar( int ch );
Writes a character ch to stdout. Internally, the character is converted to unsigned char just before being written. No cap, thatβs literally the whole vibe.
Equivalent to std::putc(ch, stdout). periodt.
πΈ Parameters πΈ
chβ the character to be written. Thatβs it, bestie. Thatβs the whole parameter list. π«Ά
π Return value π
On success, returns the written character. Slay β¨
On failure, returns EOF and sets the error indicator (see std::ferror()) on stdout. Big yikes, but thatβs the deal π.
π₯ Example π₯
// Run this code
#include <cstdio>
int main()
{
for (char c = 'a'; c != 'z'; ++c)
std::putchar(c);
// putchar return value is not equal to the argument
int r = 0x1024;
std::printf("\nr = 0x%x\n", r);
r = std::putchar(r);
std::printf("\nr = 0x%x\n", r);
}
π¦ Possible output π¦
abcdefghijklmnopqrstuvwxy
r = 0x1024
$
r = 0x24
π See also π
fputcwrites a character to a file streamputc(function)- C documentation for
putchar
mwah π β source: http://cppreference.com, version 2024.06.10, page std::putchar(3). byeee π«Ά
π¦ 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