C puts() Function Tutorial

  • Post author:
  • Post category:C

In this section, we will learn what the puts() function is and how to use it in C.

puts() Function in C

The `puts` function is used to send character-strings into the output stream.


  • The function will drop the null-character of the character-string and instead it will append a newline character.

puts() Function Syntax

int puts(const char *str)

puts() Function Parameters

This function takes the address (pointer) of a character-string that we want to send to output as its argument.

puts() Function Return Value

The return value of this function will be a non-negative value on successful operation and EOF if the operation failed for whatever reason.

Example: using puts() function in C

#include <stdio.h>
int main() {

    char array[30];

    puts("Please enter something:");

    puts("You've entered:");

    return 0;


Please enter something:

My name is John

You've entered:

My name is John

Leave a Reply