puts() — Write a String

Format

#include <stdio.h>
int puts(const char *string);

Language Level

ANSI

Threadsafe

Yes

Description

The puts() function writes the given string to the standard output stream stdout; it also appends a new-line character to the output. The ending null character is not written.

Return Value

The puts() function returns EOF if an error occurs. A nonnegative return value indicates that no error has occurred.

The value of errno may be set to:
Value
Meaning
ECONVERT
A conversion error occurred.
EPUTANDGET
An illegal write operation occurred after a read operation.
EIOERROR
A non-recoverable I/O error occurred.
EIORECERR
A recoverable I/O error occurred.

Example

This example writes Hello World to stdout.
#include <stdio.h>
 
int main(void)
{
  if ( puts("Hello World") == EOF )
    printf( "Error in puts\n" );
}
 
/************************  Expected output:  *********************
 
Hello World
*/

Related Information