What is the difference between fgets()
and gets()
?
I am trying break my loop when the user hits just "enter". It's working well with gets()
, but I don't want to use gets()
.
I tried with fgets()
and scanf()
but I don't have the same results as with gets()
. fgets()
breaks the loop whatever user enters in text! Here is my code :
void enter(void)
{
int i,
for(i=top; i<MAX; i++)
{
printf(".> Enter name (ENTER to quit): ");
gets(cat[i].name);
if(!*cat[i].name)
break;
printf(".> Enter Last Name: ");
scanf("%s",cat[i].lastname);
printf(".> Enter Phone Number: ");
scanf("%s",cat[i].phonenum);
printf(".> Enter e-Mail: ");
scanf("%s",cat[i].info.mail);
printf(".> Enter Address: ");
scanf("%s",cat[i].info.address);
printf("\n");
}
top = i;
}