title: Why does this strcmp not trigger true?
body: <p>I am trying to make a shell program and am working on mkdir, I am reading in the user input and breaking it into segments using sscanf and then trying to use strcmp to check if the first word was &quot;mkdir&quot;, the strcmp works if I leave the stdin as is without using sscanf. Can someone tell me why it doesn't work like this, and how to fix it?
  Thanks,</p>
  <pre><code>//#include &quot;parser.c&quot;
  #include &lt;stdio.h&gt;
  # include &lt;sys/stat.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  
  #ifndef MAX_BUF
  #define MAX_BUF 200
  #endif
  
  int main(void)
  {
      while (1) {
          printf(&quot;Enter a command: &quot;);
          char input[20];
          char line[4][20];
          fgets(input, 20, stdin);
          sscanf(input, &quot;%s %s&quot;, line[0], line[1]);
          if(strcmp(line[0], &quot;mkdir&quot;)) {
              char path[MAX_BUF];
              getcwd(path, MAX_BUF);
              strcat(path, &quot;/&quot;);
              strcat(path, line[1]);
              mkdir(path, 0700);
              printf(path);
          }
          
      
          //printf(&quot;output %s&quot;, input);
      }
  }
  </code></pre>