Hi, I need to enter a few data fields in a row, some of which are strings which will contain spaces. I have the code below which works fine apart from when I press enter for the membership number it skips the name field.
Also, pressing enter for the address lines skips a line in the console printing the next request for input two lines down. This is minor as it's purely a cosmetic problem but does anyone have any ideas?
Code:
printf("\nMembership Number: ");
scanf("%d", &temprec.membershipno);
printf("\nName:");
fgets(temprec.name, 25, stdin);
temprec.name[strlen(temprec.name)-1] = 0;
printf("\nAddress Line One:");
fgets(temprec.addressone, 25, stdin);
temprec.addressone[strlen(temprec.addressone)-1] = 0;
printf("\nAddress Line Two:");
fgets(temprec.addresstwo, 25, stdin);
temprec.addresstwo[strlen(temprec.addresstwo)-1] = 0;
printf("\nAge: ");
scanf("%d", &temprec.age);
Many thanks in advance!