I am facing issue with fgets when user tries to enter data for second time (skips first input).. working fine first time.. as shown in image below: enter image description here
I am using following code:
printf("Please Enter Following Information: \n\n\n");
printf("County (For Example - Hamilton,Ohio): \n");
fgets(strCounty, 49, stdin);
/* we should trim newline if there is one */
if (strCounty[strlen(strCounty) - 1] == '\n') {
strCounty[strlen(strCounty) - 1] = '\0';
}
printf("Race of head of Household (For Example - Asian): \n");
fgets(strRace, 49, stdin);
/* again: we should trim newline if there is one */
if (strRace[strlen(strRace) - 1] == '\n') {
strRace[strlen(strRace) - 1] = '\0';
}
printf("Number in Household: \n");
scanf("%d",&intHouseholds);
printf("The household yearly income: \n");
scanf("%d",&dblIncome);
I have seen a lot of related questions but haven't found the correct answer - please help.