title: C - user single char input rendering weird results
body: <p>New here and I have a very simple question. I am making a simple program in C that requires the user to enter a choice of what to do with a char. After they enter the result, the program goes back to the menu. However it seems to take some sort of ghost input as if the char has some unknown value. I need to set the char back to its default state.</p>
  
  <p>Code:</p>
  
  <pre><code>/* display menu for user */
  void menu() {
  
      printf("\n- - - Phone Book Database - - -\n");
      printf("\nSelect an action:\n\n");
      printf("\tc:\tCreate a database entry.\n");
      printf("\ts:\tSearch the database entries.\n");
      printf("\td:\tDelete a database entry.\n");
      printf("\tq:\tQuit program.\n\n");
  
      printf("Enter choice: ");
      menu_choice = getchar();
  
      if(menu_choice != 'c' &amp;&amp; menu_choice != 's'
          &amp;&amp; menu_choice != 'd' &amp;&amp; menu_choice != 'q') {
              printf("\n\n\tInvalid choice.\n");
              menu();
      }
      //fflush(stdin);
  }
  </code></pre>
  
  <p>Here is an example output:</p>
  
  <pre><code>- - - Phone Book Database - - -
  
  Select an action:
  
      c:  Create a database entry.
      s:  Search the database entries.
      d:  Delete a database entry.
      q:  Quit program.
  
  Enter choice: c
  
  Enter name: test
  
  Enter address: test
  
  Enter number: 3
  
  - - - Phone Book Database - - -
  
  Select an action:
  
      c:  Create a database entry.
      s:  Search the database entries.
      d:  Delete a database entry.
      q:  Quit program.
  
  Enter choice: 
      Invalid choice.
  
  - - - Phone Book Database - - -
  
  Select an action:
  
      c:  Create a database entry.
      s:  Search the database entries.
      d:  Delete a database entry.
      q:  Quit program.
  
  Enter choice: q
  </code></pre>
  
  <p>Entering c as an input calls the following function</p>
  
  <pre><code>/* creates a new record in array */
  void create_record() {
      char name[MAX];
      char address[MAX];
      int number;
  
      rec_num++; /* add 1 to marker for record placement */
  
      printf("\nEnter name: ");
      scanf("%s", name);
  
      printf("\nEnter address: ");
      scanf("%s", address);
  
      printf("\nEnter number: ");
      scanf("%d", &amp;number);
  
      strcpy(record[rec_num].name, name);
      strcpy(record[rec_num].address, address);
      record[rec_num].number = number;
  }
  </code></pre>