std::puts(3)
π
std::puts(3) β C++ Standard Library, but make it cute π
Okay so bestie, this is the manual page for std::puts, straight from the C++ Standard Library. She writes strings, she adds newlines, sheβs lowkey iconic. Letβs get into it. π
π NAME π
std::puts β literally std::puts. Thatβs the name, no cap. She lives in the C++ Standard Library and her whole thing is writing a string plus a newline to stdout. β¨
β¨ Synopsis β¨
Defined in header <cstdio>:
int puts( const char *str );
Writes every character from the null-terminated string str and one additional newline character '\n' to the output stream stdout, as if by repeatedly executing std::fputc.
The terminating null character from str is not written. Not even a little. π
πΈ Parameters πΈ
strβ character string to be written
π Return value π
- On success, returns a non-negative value.
- On failure, returns
EOFand sets the error indicator (seestd::ferror) onstdout.
π¦ Notes π¦
- The
std::putsfunction appends the newline character to the output, while thestd::fputsfunction does not. Thatβs the whole difference, and sheβs serving it. π - Different implementations return different non-negative numbers: some return the last character written, some return the number of characters written (or
INT_MAXif the string was longer than that), some simply return a non-negative constant. - A typical cause of failure for
std::putsis running out of space on the file system, whenstdoutis redirected to a file.
π Example π
// Run this code
#include <cstdio>
int main()
{
int rc = std::puts("Hello World");
if (rc == EOF)
std::perror("puts()"); // POSIX requires that errno is set
}
β Output β
Hello World
π₯ See also π₯
fputsβ writes a character string to a file stream (function)printffprintfβ prints formatted output tostdout, a file stream or a buffersprintf(function)snprintf(C++11)- C documentation for
puts
Source/version/date vibes: http://cppreference.com, 2024.06.10, for this std::puts(3) page β mwah, go slay those null-terminated strings bestie πβ¨π«Ά
π¦ 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