Home » C programs » stdio.h header file functions

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


Comments and Discussions




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.