Facebook Page Twitter Page LinkedIn Page
× C Standard Library

The C <stdio.h> puts() function writes every character of the null-terminated string pointed to by str and one additional newline character '\n' to the output stream stdout. The terminating null-character is not copied to the stream.

fputs() and puts() are equivalent functions except puts() uses stdout as destination and appends a newline character at the end automatically.


int puts ( const char * str );


str Specify a null-terminated character string to be written.

Return Value

On success, returns a non-negative value. On failure, returns EOF and sets the error indicator ferror().


The below example shows the usage of puts() function.

#include <stdio.h>
int main (){
  char str[50] = "Hello World!";

  //prints str
  return 0;

The output of the above code will be:

Hello World!

❮ C <stdio.h> Library