I am working on my c project,just started.I need to get "Name" from users input.
fgets() works fine inside the main function,but skipped when used outside the main function.I found many related questions,so i read all the answers but i cannot solve my problem.
After reading some answer,I tried using "fflush(stdin)", scanf("[%^\n]") but no reslove.
void newacc()
{
struct tenant new;
printf("Enter Name:");
fgets(new.name,20,stdin);
printf("\nEnter Phone number:\n");
scanf("%d",&new.ph);
printf("Enter Rental Date (DD-MM-YYYY):\n");
scanf("%d%d%d",&new.td.dd,&new.td.mm,&new.td.yy);
}