Search Your Topic

Thursday, 22 June 2017 03:07

C gets() and puts() functions

Written by
Rate this item
(0 votes)

The gets() function reads string from user and puts() function prints the string. Both functions are defined in <stdio.h> header file.

Let's see a simple program to read and write string using gets() and puts() functions.

  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. void main(){  
  4.     char name[50];  
  5.     clrscr();  
  6.     printf("Enter your name: ");  
  7.     gets(name); //reads string from user  
  8.     printf("Your name is: ");  
  9.     puts(name);  //displays string  
  10.     getch();  
  11. }  


Enter your name: Sonoo Jaiswal
Your name is: Sonoo Jaiswal
Read 1321 times
Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

 Call +91 74 88 34 7779  | Email :
More in this category: « Strings in C C String Functions »

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.