title: Relational operator operating on strings in c++ not working as expected
body: <pre><code>int main() 
  { 
      string s1("z"); 
      string s2("ab"); 
      if(s1 &gt; s2) cout &lt;&lt; s1 &lt;&lt; " is greater than " &lt;&lt; s2 &lt;&lt; endl;
      cout &lt;&lt; ("z" &gt; "ab") &lt;&lt; endl;
      return 0; 
   }
  </code></pre>
  
  <p>And the output is </p>
  
  <pre><code>z is greater than ab
  0
  </code></pre>
  
  <p>I am a bit confused as in the 3rd statement s1 > s2 does a lexographical compare and the result is expected, but the statement 4 returns a 0 value. </p>
  
  <p>Thanks, as it's driving me crazy</p>
  
  <p>Update ------</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  int main() 
  { 
      string s1("z"); 
      string s2("ab"); 
      cout &lt;&lt; &amp;s1 &lt;&lt; " " &lt;&lt; &amp;s2 &lt;&lt; endl;
      if(s1 &gt; s2) cout &lt;&lt; s1 &lt;&lt; " is greater than " &lt;&lt; s2 &lt;&lt; endl;
      cout &lt;&lt; ("z" &gt; "ab") &lt;&lt; endl;
      cout &lt;&lt; ("ab" &gt; "z") &lt;&lt; endl;
      cout &lt;&lt; &amp;("ab") &lt;&lt;  " "  &lt;&lt; &amp;("z") &lt;&lt; endl;
      return 0; 
  }
  </code></pre>
  
  <p>The above code helped me. </p>