title: C: switch statement not working?
body: <p>Ok, so fgets reads lines from file redirection input and then uses those lines to evaluate a switch statement.<br>
  I am trying to test case '1' however it is not working.<br>
  This is my output:
  <code>DATA SET ANALYSIS
  1. Show all the data
  2. Calculate the average for an experiment
  3. Calculate the average across all experiments
  4. Quit
  Selection: 1</code></p>
  
  <p>Does anyone understand why none of my switch statement is running? Clearly <code>var</code> is equal to 1, so the switch should be at the very least printing <code>HELLO</code>, however it does nothing. Help?</p>
  
  <pre><code>while(fgets(str,100,stdin) != NULL &amp;&amp; (strcmp(str,"4") &amp;&amp; strcmp(str,"4\n")))
      {
          var = atoi(str);
          printf("DATA SET ANALYSIS\n1.\tShow all the data\n2.\tCalculate the average for an experiment\n3.\tCalculate the average across all experiments\n4.\tQuit\nSelection: %d\n",var);
          switch(var)
          {
          case '1' :
              printf("HELLO\n");
              for(j=0;j&lt;i;j++)
              {
                  printf("%s",experiments[j]);
                  for(k=0;k&lt;10;k++)
                  {
                      printf("%d ",data[j][k]);
                  }
                  printf("\n");
              }
              break;
          }
      }
  </code></pre>