puts() Library Function with Examples

puts() is unformatted string output functions. It writes or prints string to screen. It is defined in standard header file stdio.h.

puts() Syntax


puts(string or string_variable);

puts() Examples

Example #1 : Displaying String Using puts() Function


#include<stdio.h>
#include<conio.h>

void main()
{
  char name[100];
  clrscr(); /* Clear the screen */
  printf(“Enter your name:\n”);
  gets(name);
  puts(“Hello,”);
  puts(name);
  puts(“Have a good day.”);
  getch(); /* Holding output */
}

Output of the above program :

Enter your name:
Ramesh Bhandari ↲
Hello,
Ramesh Bhandari
Have a good day.

Note: ↲ indicates enter is pressed.