title: How to compare user input (from std::cin) to a string?
body: <p>So this one sounds very easy but I am getting some strange behavior. </p>
  
  <p>In my program there is the following code:</p>
  
  <pre><code>std::cout &lt;&lt; "Would you like to generate a complexity graph or calculate global complexity? (graph/global)\n";
  char ans[6];
  std::cin &gt;&gt; ans;
  
  if (ans != "global") std::cout &lt;&lt; "&gt;&gt;" &lt;&lt; ans &lt;&lt; "&lt;&lt;" &lt;&lt; std::endl;
  </code></pre>
  
  <p>When I run my program and type in "global" when I'm prompted for input, the program returns:</p>
  
  <pre><code>&gt;&gt;global&lt;&lt;
  </code></pre>
  
  <p>Why does the if statement evaluate as <code>true</code>?</p>