I am having a problem with fgets() waiting for stdin. Any help is appreciated.
Code:
#include <stdio.h>
struct myPIM
{
char firstname[15];
char lastname[20];
char homeaddr[30];
char city[30];
char state[3];
long int zip;
};
main()
{
struct myPIM person1;
printf("Person # 1\n");
printf("Firstname: ");
scanf("%s", person1.firstname);
printf("Lastname: ");
scanf("%s", person1.lastname);
printf("Street Address: ");
fgets(person1.homeaddr, 30, stdin);
printf("City: ");
scanf("%s", person1.city);
printf("State: ");
scanf("%s", person1.state);
printf("Zipcode: ");
scanf("%ld", &person1.zip);
/* print the entered information */
printf("\n\n*** Your Personal Information ***\n");
printf("Firstname: %s\n", person1.firstname);
printf("Lastname: %s\n", person1.lastname);
printf("Street Address: %s\n", person1.homeaddr);
printf("City: %s\n", person1.city);
printf("State: %s\n", person1.state);
printf("ZipCode: %ld\n", person1.zip);
}