Get or Read String using Gets()
On this page (6sections)
Get or Read String Using gets()
gets() accepts single or multiple characters of string including spaces from the standard Input device.
Declaration:
gets(variable_name);
Example Declaration:
char ch[10];
gets(ch);
Remarks:
gets() read string from the screen.
Example Program:
#include<stdio.h>
#include<conio.h>
void main()
{
char a[20];
gets(a);
puts(a);
getch();
}
Sample Output:
thiyagaraaj.com
thiyagaraaj.com
Related Pages
Continue learning with these related tutorials and programs:
- C Tutorials — Browse all C Tutorials.
- C Data Input and Data Output — Overview — printf, scanf and I/O basics.
- Single Character Input Function : getchar() — More in c data input and ouput.
- Single Character Input Function : getche() — More in c data input and ouput.