CKTIS / C
puts — write text with a newline
The puts function from <stdio.h> writes a string to stdout, appends a newline, and returns a result indicating success or failure.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stdio.h>
int puts(const char *s);puts(s) writes a string to stdout and appends \n. The terminating \0 is not written. The argument must point to a valid null-terminated string; NULL is invalid.
The function does not interpret format specifiers. An existing trailing \n produces an extra blank line. Unlike puts, fputs lets you choose the stream and does not append a newline.
The result is EOF on a write error, otherwise a nonnegative value—not necessarily a character count. Buffering can delay error detection; the example also checks fflush(stdout).
Examples
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
if (puts("Hello, C!") == EOF) {
return EXIT_FAILURE;
}
if (fflush(stdout) == EOF) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Result
Hello, C!
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.