Home »
C programs »
C stdio.h library functions programs
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.
Prototype:
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
gets(ch);
printf("\nThe string is - ");
//print the string
puts(ch);
return 0;
}
Output
C stdio.h Library Functions Programs »