Monday, 17 September 2012

gets function


This special function is used to input string values from the user during execution of the program. As the user press enter key when typing after the string. A null character (\0) is automatically entered at the end of the string.
Syntax:
gets(variable name);
Example:

#include<stdio.h>
#include<conio.h>
void main ()
{
char str[];
clrscr();
printf("Enter a string:");
gets(str);
getch();
}
Output:
Enter a string:hello