I am having a problem with a for loop. When I go through the second iteration, the program does not wait for user input. Any help gratefully accepted.
#include <stdio.h>
#include "dogInfo.h"
main()
{
struct dogInfo dog[3]; //Array of three structure variable
int ctr;
//Get information about dog from the user
printf("You will be asked to describe 3 dogs\n");
for (ctr = 0; ctr < 3; ctr ++)
{
printf("What type (breed) of dog would you like to describe for dog #%d?\n", (ctr +1));
gets(dog[ctr].type);
puts("What colour is the dog? ");
gets(dog[ctr].colour);
puts("How many legs does the dog have? ");
scanf(" %d", &dog[ctr].legNum);
puts("How long is the snout of the dog in centimetres? ");
scanf(" %.2f", &dog[ctr].snoutLen);
getchar(); //clears last new line for the next loop
}
The header file is as below
struct dogInfo
{
char type[25];
char colour[25];
int legNum;
float snoutLen;
};