title: gets() does not work
body: <p>I have a program written in C and it calls gets() from a switch when a user chooses the option of 3. Here is my code. It does not seem to wait to wait for the user to input something. Rather the program continues in the switch.</p>
  
  <pre><code>void getField();
  
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  /*#include "stubs.c"
  #include "record.h" */
  
  int debugMode;
  
  void getField(){
      char name[25];
      char address[80];
      int yearofbirth;
      char telno[15];
      int counter = 0;
  
      if(debugMode == 1){
          printf("***DEBUG*** Entering getField function \n");
      }
  
      printf("Enter your name:");
      gets(name);
  
      printf("Name: %s \n", name);
      printf("\n");
  }
  
  void main(int argc, char * argv[])
  {
      struct record* start = NULL;
      int userChoice;
      debugMode = 0;
  
      if(argv[1] != NULL){
          if( (strcmp(argv[1], "debug") == 0) &amp;&amp; (argv[2] == NULL) ){
              debugMode = 1;
              printf("Welcome, to the personal address book application \n");
          }
          else{
              int i = 0;
              while(argv[i] != NULL){
                  printf(argv[i]);
                  printf(" ");
                  i++;
              }
              printf(": Command not found \n");
              userChoice = 6;
          }
      }
  
      if(argv[1] == NULL){
          printf("Welcome, to the personal address book application \n");
          userChoice = 0;
      }
  
  
      while(userChoice != 6)
      {
          if(debugMode == 1){
              printf("***DEBUG*** Entering do-while loop \n");
          }
  
          printf("Enter number corresponding number to option below \n\n");   
  
          printf("1) Add a new record in the database \n");
          printf("2) Modify a record in the database \n");
          printf("3) Print information about a record in the database \n");
          printf("4) Print all information in the database \n");
          printf("5) Delete an existing record from the database \n");
          printf("6) Quit program \n\n &gt;");
  
  
          scanf("%d", &amp;userChoice);
  
          switch(userChoice){
  
              case 1:
                  /*addRecord(start, arrayHolder, arrayHolder, 0, arrayHolder);
                  */userChoice = 0;
                  break;
              case 2:
                  /*modifyRecord(start, arrayHolder, arrayHolder, arrayHolder);
                  */userChoice = 0;
                  break;
              case 3:
                  /*printRecord(start, arrayHolder);
                  */userChoice = 0;
                  getField();
                  break;
              case 4:
                  /*printAllRecords(start);
                  */userChoice = 0;
                  break;
              case 5:
                  /*deleteRecord(start, arrayHolder);
                  */userChoice = 0;
                  break;
              case 6:
                  printf("case 6 \n");
                  break;
              default:
                  printf("default \n");
                  userChoice = 0;
                  break;
          }
  
      }
      printf("\n");
  }
  </code></pre>