Data Input and Output Gets and Puts Example in C
On this page (7sections)
About this program
This is an example program in **data input and output programs in c **. Read the concept first: printf and scanf in C, then study the code and output below.
Definition for gets() and puts()
- gets() : Reads characters from the standard input and stores them as a string.
- puts() : prints characters from the standard output.Just like printf statement.
Syntax for gets() and puts()
gets(char_array_variable);
puts(char_array_variable/string);
Library for gets() and puts()
#include <stdio.h>
Simple Example Program For gets() and puts()
/* Example Program For gets() and puts() In C Programming Language
little drops @ thiyagaraaj.com
Coded By:THIYAGARAAJ MP */
// Header Files
#include<stdio.h>
#include<conio.h>
//Main Function
int main()
{
char data[100];
printf("Enter a String for gets() :");
//get string input using gets(..) function
gets(data);
printf("Entered Data Is : will be with puts() :");
//print string using puts(..) function
puts(data);
// Wait For Output Screen
getch();
//Main Function return Statement
return 0;
}
Sample Output:
Enter a String:Programming
Entered Data Is :Programming
Related Pages
Learn the concept first, then study the code:
- C Programs — Browse all C Programs.
- printf and scanf in C — Tutorial — formatted input and output.
- Printf And Scanf Example Program In C Programming — More in data input and output programs in c .
- Data Output printf and putchar Example Program In C — More in data input and output programs in c .