title: Something wrong with character input and switch case in C?
body: <p>There is a question in which it takes the no: of cases and in each case it takes no: of objects and each object is either a point or circle or line segment. I have written complete code but the switch case is not working. Any suggestions are appreciated.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;stdlib.h&gt;
  
  int main()
  {
      int test,nob,ans[4],px,py,cx,cy,cr,lx1,ly1,lx2,ly2,flag,i,j;
      char type;
  
      scanf("%d",&amp;test); //no:of test cases
  
      while(test) {
  
          flag=0;
          scanf("%d",&amp;nob); //no:of objects
          while(nob)
          {
              scanf("%c\\n",&amp;type); //what type of object
              switch(type)
              {
              case 'p':
                  {
                      scanf("%d%d",&amp;px,&amp;py);
                      if((px&lt;=ans[0] &amp;&amp; py&lt;=ans[1] &amp;&amp; px&gt;=ans[2] &amp;&amp; py&gt;=ans[3])|| flag==0) {
                          ans[0]=px;ans[1]=py;ans[2]=px;ans[3]=py;
                      }
                      break;
                  }
              case 'c':
                  {
                      scanf("%d%d%d",&amp;cx,&amp;cy,&amp;cr);
                      if((cx-cr&lt;=ans[0] &amp;&amp; cy-cr&lt;=ans[1] &amp;&amp; cx+cr&gt;=ans[2] &amp;&amp; cy+cr&gt;=ans[3])|| flag==0) {
                          ans[0]=cx-cr;ans[1]=cy-cr;ans[2]=cx+cr;ans[3]=cy+cr;
                      }
                      break;
                  }
              case 'l':
                  {
                      scanf("%d%d%d%d",&amp;lx1,&amp;ly1,&amp;lx2,&amp;ly2);
                      if((lx1&lt;=ans[0] &amp;&amp; ly1&lt;=ans[1] &amp;&amp; lx2&gt;=ans[2] &amp;&amp; ly2&gt;=ans[3])|| flag==0) {
                          ans[0]=lx1;ans[1]=ly1;ans[2]=lx2;ans[3]=ly2;
                      }
                      break;
                  }
              default:
                  printf("you entered wrong letter.");
              }
              flag=1;
              nob--;
          }
          for(i=0;i&lt;4;i++)
          {
              printf("%d ",ans[i]);
          }
          printf("\n");
          test--;
      }
      return 0;
  }
  </code></pre>
  
  <p>When you run this program, the <code>switch case</code> is not working. I think so there is something wrong in taking the input of type character. pls help me. I have been trying to solve this bug for 3 days.</p>