title: Infinite loop with 'char' type input
body: <p>I am learning binary search tree. Given below is the main function of a program to perform basic BST operations. The <code>option</code> variable chooses which operation to perform for <code>switch</code></p>
  
  <pre><code>int main()
  {
  struct node* tree=NULL;
  struct node* ptr=NULL;
  struct node* ptrm=NULL;
  int val;
  int option;
  do
  {
      printf("\n1.Insert Node\n2.Preorder Traversal\n3.Postorder Traversal\n4.Inorder Traversal\n5.find_smallest_element\n6.find_largest_element\n7.Delete Element\n8.Total_nodes\n9.total_external_nodes\n10.total_internal_nodes\n11.Mirror image\n12.Exit\n");
      printf("\nEnter option");
      scanf("%d",&amp;option);
      switch(option)
      {
          case 1:
              printf("\nEnter value to be inserted");
              scanf("%d",&amp;val);
              tree=insert_element(&amp;tree,val);
              printf("\n%d Inserted\n",val);
              break;
          case 2:
              preorder(&amp;tree);
              break;
          case 3:
              postorder(&amp;tree);
              break;
          case 4:
              inorder(&amp;tree);
              break;
          case 5:
              ptr=find_smallest_element(&amp;tree);
              printf("\nSmallest element:%d",ptr-&gt;data);
              break;
          case 6:
              ptr=find_largest_element(&amp;tree);
              printf("\nLargest element:%d",ptr-&gt;data);
              break;
          case 7:
              printf("\nEnter value of element to be deleted");
              scanf("%d",&amp;val);
              tree=delete_node(&amp;tree,val);
              break;
          case 8:
              printf("\nTotal nodes%d",total_nodes(&amp;tree));
              break;
          case 9:
              printf("\nTotal External nodes%d",total_external_nodes(&amp;tree));
              break;
          case 10:
              printf("\nTotal Internal nodes%d",total_internal_nodes(&amp;tree));
              break;
          case 11:
              ptrm=mirror_image(&amp;tree);
  
      }
  }while(option!=12);
  return 0;
  </code></pre>
  
  <p>Everything works fine when i give int data as input for 'option'.However, when i give a char input the program goes into infinite loop and displays option list repeatedly.</p>
  
  <p>Why does this happen?</p>