title: Warning: comparison with string literals results in unspecified behaviour
body: <p>I am starting a project of writing a simplified shell for linux in C. I am not at all proficient with C nor with Linux that's exactly the reason I decided it would be a good idea. </p>
  
  <p>Starting with the parser, I have already encountered some problems.</p>
  
  <p>The code should be straightforward that's why I didn't include any comments. </p>
  
  <p>I am getting a warning with gcc: "comparison with string literals results in unspecified behaviour" at the lines commented with "WARNING HERE" (see code below). </p>
  
  <p>I have no idea why this causes an warning, but the real problem is that even though I am comparing an "&lt;" to an "&lt;" is doesn't get inside the if...</p>
  
  <p>I am looking for an answer for the problem explained, however if there's something that you see in the code that should be improved please say so. Just take in mind I am not that proficient and that this is still a work in progress (or better yet, a work in start).</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  
  typedef enum {false, true} bool;
  
  typedef struct {
      char **arg;
      char *infile;
      char *outfile;
      int background;
  } Command_Info;
  
  int parse_cmd(char *cmd_line, Command_Info *cmd_info)
  {
      char *arg;
      char *args[100];    
  
      int i = 0;
      arg = strtok(cmd_line, " \n");
      while (arg != NULL) {
          args[i] = arg;
          arg = strtok(NULL, " \n");
          i++;
      }
  
      int num_elems = i;
  
      cmd_info-&gt;infile = NULL;
      cmd_info-&gt;outfile = NULL;
      cmd_info-&gt;background = 0;
  
      int iarg = 0;
      for (i = 0; i &lt; num_elems; i++)
      {
          if (args[i] == "&amp;") //WARNING HERE
              return -1;      
          else if (args[i] == "&lt;") //WARNING HERE
              if (args[i+1] != NULL)
                  cmd_info-&gt;infile = args[i+1];
              else
                  return -1;
  
          else if (args[i] == "&gt;") //WARNING HERE
              if (args[i+1] != NULL)
                  cmd_info-&gt;outfile = args[i+1];
              else
                  return -1;          
  
          else 
              cmd_info-&gt;arg[iarg++] = args[i];
      }
  
      cmd_info-&gt;arg[iarg] = NULL;
  
      return 0;   
  }
  
  void print_cmd(Command_Info *cmd_info)
  {
      int i;  
      for (i = 0; cmd_info-&gt;arg[i] != NULL; i++)
          printf("arg[%d]=\"%s\"\n", i, cmd_info-&gt;arg[i]);
      printf("arg[%d]=\"%s\"\n", i, cmd_info-&gt;arg[i]);    
      printf("infile=\"%s\"\n", cmd_info-&gt;infile);
      printf("outfile=\"%s\"\n", cmd_info-&gt;outfile);
      printf("background=\"%d\"\n", cmd_info-&gt;background);
  }
  
  int main(int argc, char* argv[])
  {
      char cmd_line[100];
      Command_Info cmd_info;
  
      printf("&gt;&gt;&gt; ");
  
      fgets(cmd_line, 100, stdin);
  
      parse_cmd(cmd_line, &amp;cmd_info);
  
      print_cmd(&amp;cmd_info);
  
      return 0;
  }
  </code></pre>