Ok this program is supposed to small database for at least 5 people.
I thought i had it right when i compiled and built it had 0 errors, but when I ran it, it would skip over certain input fields and just go to the next. Then when it's supposed to print out the results in the end I get the wrong inputs.
Any help is appreciated.
TIA
Code:
#include <stdio.h>
main(void)
{
int num;
int count;
struct people
{
char full_name[50];
int age;
float weight;
char state[2];
char occupation[50];
} person[50];
printf("How many people would you like to include?\n");
scanf("%d", &num);
for(count = 0; count< num; count++)
{
printf("Your full name\n");
gets(person[count].full_name);
printf("Your age\n");
scanf("%d", &person[count].age);
printf("Your weight\n");
scanf("%f", &person[count].weight);
printf("Your state\n");
scanf("%c", &person[count].state);
printf("Your occupation\n");
gets(person[count].occupation);
}
printf("These are your results:\n");
for(count=0; count< num; count++)
{
printf("%c\n", person[count].full_name);
printf("%d\n", person[count].age);
printf("%f\n", person[count].weight);
printf("%c\n", person[count].state);
printf("%c\n", person[count].occupation);
}
return (0);
}