puts C 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 using 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 : ");

Enter your name
Jack Dawson
You name is : Jack Dawson