#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
struct user
{
char name[30];
char accNo[20];
char phoneNo[15];
char password[20];
};
int main()
{
int choice;
struct user Deepak;
printf("select your choice\n\n");
printf("1. Open new account.\n\n");
printf("2. Login to account.\n\n");
printf("Your choice : ");
scanf("%d", &choice);
if (choice == 1)
{
system("cls");
printf("Enter your name : ");
fgets(Deepak.name, sizeof(Deepak.name),stdin);
printf("Enter your phone number : ");
scanf("%s",Deepak.phoneNo);
printf("Create your password : ");
scanf("%s",Deepak.password);
}
return 0;
}
Here in line 31 the fgets is not taking inputs and directly jumping to the line 33. I tried scanf("%[^\n]%*c",input)
but it did not work either. So I used the fgets but it is also not working. How can I fix it?