title: gets() not working for me
body: <p>Quick issue with my code. Please look in the function enter(). When I request the name, and use gets(), it just skips it as if nothing was there, and jumps to requesting the age. What am I doing incorrectly?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #define RECORDS 30
  #define LEN 20
  
  /*Questions
  Formatting display() - can we use spaces to format?
  Is the patient structure supposed to be global or local in enter()?
  Why doesn't printf("name: "); scanf("%s", name); require &amp;name?
  Make sure you account for first and last names, use getline or something
  */
  
  void enter();
  
  struct patient
  {
      char name[LEN];
      int age;
      double highBP, lowBP, riskFactor;
  };
  
  struct patient * db[RECORDS];
  int counter = 0;
  
  main()
  {
      int flag = 1;
  
      while (flag == 1)
      {       
          printf("---------------------------------------------------------\n");
          printf("|\t(N)ew record\t(D)isplay db\t(U)pdate record |\n");
          printf("|\t(L)oad disk\t(W)rite disk\t(E)mpty disk    |\n");
          printf("|\t(S)ort db\t(C)lear db\t(Q)uit          |\n");
          printf("---------------------------------------------------------\n");
          printf("choose one: ");
  
          char selection, selectionstr[3];
          scanf("%s",selectionstr);
          selection = selectionstr[0];        
  
          //printf("selection %c\n", selection);
  
          if ((selection == 'n') || (selection == 'N'))
          {
              //New record
              enter();
          }
  
              // Options omitted...
  
          else
          {
              printf("not a vaild input\n");  
          }
      }
  }
  
  void enter()
  {
      if (counter &lt; 30)
      {
          FILE *fptr;
          fptr = fopen("db.txt", "a");
  
          char name[LEN];
          int age;
          double highBP, lowBP;
          printf("name: "); //scanf("%s", name);
          gets(name);
          printf("age: "); scanf("%d", &amp;age);
          printf("high bp: "); scanf("%lf", &amp;highBP);
          printf("low bp: "); scanf("%lf", &amp;lowBP);
          struct patient temp;
          strcpy(temp.name, name);
          temp.age = age;
          temp.highBP = highBP;
          temp.lowBP = lowBP;
  
          if ((highBP &lt; 120) &amp;&amp; (lowBP &lt; 80))
              temp.riskFactor = 0;
  
          if (((highBP &lt;= 120) &amp;&amp; ((lowBP &gt; 80) &amp;&amp; (lowBP &lt;= 90))) || ((highBP &lt;= 80) &amp;&amp; ((lowBP &gt; 120) &amp;&amp; (lowBP &lt;= 130))))
              temp.riskFactor = 1;
  
          if (((highBP &lt;= 120) &amp;&amp; ((lowBP &gt; 90) &amp;&amp; (lowBP &lt;= 100))) || ((highBP &lt;= 80) &amp;&amp; ((lowBP &gt; 130) &amp;&amp; (lowBP &lt;= 140))))
              temp.riskFactor = 4;
  
          else
              temp.riskFactor = 5;
  
          if ((temp.riskFactor &gt; 0) &amp;&amp; (temp.age &gt; 50))
              temp.riskFactor += 0.5;
  
          db[counter] = &amp;temp;
          //fprintf(fptr, "%s, %d, %f, %f, %f\n", db[counter]-&gt;name, db[counter]-&gt;age, db[counter]-&gt;highBP, db[counter]-&gt;lowBP, db[counter]-&gt;riskFactor);
          printf("%s, %d, %f, %f, %f\n", db[counter]-&gt;name, db[counter]-&gt;age, db[counter]-&gt;highBP, db[counter]-&gt;lowBP, db[counter]-&gt;riskFactor);
          counter++;
  
          fclose(fptr);
      }
  
      else
          printf("database full");
  
  
      /*db[counter] = (struct patient *) malloc(sizeof(struct patient));
  
  
      printf("name: "); scanf("%s", (*db[counter]).name);
      printf("age: "); scanf("%d", (*db[counter]).age);
      printf("high bp: "); scanf("%d", (*db[counter]).highBP);
      printf("low bp: "); scanf("%d", (*db[counter]).lowBP);
  
  
      //db[counter] = &amp;temp;
      printf("%d", sizeof(db[counter]));
      //printf("%s", (db[counter])-&gt;name);
      printf("%s, %d, %f, %f\n", db[counter]-&gt;name, db[counter]-&gt;age, db[counter]-&gt;highBP, db[counter]-&gt;lowBP);
      counter++;*/
  }
  </code></pre>