Sunday 5 March 2017

C Program or C++ Program to input full text

Example program to show the use of gets() and puts()functions

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
charstr[40];  // array of 40 characters

// using cin/cout
cout<<"\n Enter any string:\n";
cin>>str;
cout<<"\n your string is  :\n"<<str;

// using gets/puts
cout<<"\n Enter again string:\n";
gets(str);
cout<<"\n Now your stringis  :\n";
puts(str);
}
Output of Example program 
Enter any string:
God is great nothing is hidden for him.
yourstring is  :
God

Enter again string:
God is great nothing is hidden for him.
yourstring is  :
God is great nothing is hidden for him.


No comments:

Post a Comment