Cannot input from "gets()"
<p>I wrote a c program that prompts the user enter their account information into the system and then print them out. I tried to use "gets()" to capture strings. However, it skipped the question for user's address and jumped into the question for state and city. I believed the problem is the "gets()"function. Could someone please help me with it?</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#define MAXLEN 40
struct account
{
    long unsigned number;
    char address[MAXLEN];
    char cityState[MAXLEN];
    int zip;
    double balances;
    double credit;
    char name[MAXLEN];
};

int main(void)
{
    struct account memebr;
    puts("Please enter the account number");
    scanf("%lu", &amp;memebr.number);
    puts("Please enter the street address");
    while(getchar() != '\n')
        gets(memebr.address);
    puts("Please enter your city/state");
    while(getchar() != '\n')
        gets(memebr.cityState);
    puts("Please enter your zip code");
    scanf("%d", &amp;memebr.zip);
    puts("Please enter your balances");
    scanf("%lf", &amp;memebr.balances);
    puts("Please enter your credit limit");
    scanf("%lf", &amp;memebr.credit);
    puts("Please enter your name");
    while(getchar() != '\n')
        gets(memebr.name);

    printf("Account number: %lu\n", memebr.number);
    printf("The street address is : %s\n", memebr.address);
    printf("The owner comes from: %s\n", memebr.cityState);
    printf("The zip code is: %d\n", memebr.zip);
    printf("The owner's balances: %.2f\n", memebr.balances);
    printf("The owner's credit limit: %.2f\n", memebr.credit);
    printf("The owener is: %s\n", memebr.name);
    return 0;

}
</code></pre>