Monday 3 December 2018

what is gets function in c++

gets() function


 function
gets function

gets() is a standard library function defined in stdio.h header file which is used to
get a string from the keyboard.Its general syntax is:

gets(string variable name);


It reads characters from stdin and stores them as a string into ‘string variable’ until
a newline character of the EOF is reached.Consider the following exemple:

/*gets example*/

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

Int main()
{
char TestStr[150];

cout <<”insert your full address:”;

gets(TestStr);

cout<<”\nYour address is :”<<TestStr;

getch();

return 0;
} 

Output of the Program

Insert your full address: H.No. 12 lalazar colony kohat

Your address is: H.No. 12 lalazar colony kohat 

0 comments: