puts() function in C language with Example

Here, we are going to learn about the puts() function of library function stdio.h in C language with its syntax, example.
Submitted by Souvik Saha, on February 22, 2019

puts() function in C

The puts() function is defined in the <stdio.h> header file.


    int puts(const char *string);

Parameters: const char *string

Return type: int

Use of function:

Through the puts() function, we write the string to the output stream stdout which are stored into the character array until it encounters the newline character. The prototype of the function puts() is int puts(const char *string);

Here string is the array of characters which are written to the stream. It returns a non-negative value for the successful operation and EOF for failure.

puts() example in C

#include <stdio.h>

int main()
    char ch[100];

    printf("Enter any string\n");
    //get the string

    printf("\nThe string is - ");
    //print the string

    return 0;


puts() example in C language

C stdio.h Library Functions Programs »

Comments and Discussions!

Load comments ↻

Copyright © 2024 www.includehelp.com. All rights reserved.