puts : <stdio.h> library function

The function int puts(const char *str); writes a null terminated string pointed by str to the standard output(stdout) stream and appends a newline character('\n').

Function prototype of puts

int puts(const char *str);
  • str : This is the pointer to a C string to be written on stdout stream.

Return value of puts

On Success, puts function returns a non-negative value otherwise returns EOF in case of an error.

C program to show the use of puts function

The following program shows the use of puts function to write a string on console.

#include <stdio.h>

int main(){
   char string[50];

   printf("Enter your name\n");

   printf("You name is : ");

Program Output
Enter your name
Jack Dawson
You name is : Jack Dawson