#include<stdio.h>
#include<string.h>
int main()
{
char name[10][30];
int i,n;
printf("How many names?\n");
scanf("%d",&n);
printf("Enter names\n");
for(i=0;i<n;++i)
gets(name[i]);
printf("\n The names are\n");
for(i=0;i<n;++i)
printf("%s\n",name[i]);
}
I am trying to sort the full name of persons in order. So I read total number of names and store the names in an array of string. But the problem is when this program is executed:
How many names
4
Enter names
john G
susan sing
puskar
The names are
john G
susan sing
puskar
I am not getting why an empty string is been read.