title: comparison between string literal
body: <p>This very simple code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void exec(char* option)
  {
      cout &lt;&lt; "option is " &lt;&lt; option &lt;&lt; endl;
      if (option == "foo")
          cout &lt;&lt; "option foo";
      else if (option == "bar")
          cout &lt;&lt; "opzion bar";
      else
          cout &lt;&lt; "???";
      cout &lt;&lt; endl;
  }
  
  int main()
  {
      char opt[] = "foo";
      exec(opt);
      return 0;
  }
  </code></pre>
  
  <p>generate two warning: comparison with string literal results in unspecified behaviour.</p>
  
  <p>Can you explain why exactly this code doesn't work, but if I change</p>
  
  <pre><code>char opt[]
  </code></pre>
  
  <p>to</p>
  
  <pre><code>char *opt
  </code></pre>
  
  <p>it works, but generates the warning? Is it related to the \0 termination? What is the difference between the two declaration of opt? What if I use const qualifier? The solution is to use std::string?</p>