I have tried to make a function that inputs the type, name and the age of an animal. For the first animal it works just fine but for the second it skips the type. Any idea?
inputAnimalDetails(&ani1);
inputAnimalDetails(&ani2);
void inputAnimalDetails(animal* animal)
{
char type[LEN] = { 0 };
char name[LEN] = { 0 };
int age = 0;
printf("Enter animal type: ");
fgets(type, LEN, stdin);
type[strcspn(type, "\r\n")] = 0;
strcpy(animal->type, type);
printf("Enter animal name: ");
fgets(name, LEN, stdin);
name[strcspn(name, "\r\n")] = 0;
strcpy(animal->name, name);
printf("Enter animal age: ");
scanf("%d", &age);
animal->age = age;
}