title: Checking reversed text on C++ (doesn't work with a -1 index?)
body: <p>I was making a simple palindrome checker and can't understand why the iterator works with index 0,  but won't work with index -1, you can see that both codes print the SAME text, but not the same boolean.</p>
  <p>Can anyone explain me what's the logic behind this?</p>
  <p>The only different part on both codes is this:</p>
  <blockquote>
  <p>for(int i=text.size();i&gt;=<strong>-1</strong>;i--) <i>Not Working</i><br>
  for(int i=text.size()<strong>-1</strong>;i&gt;=<strong>0</strong>;i--) <i>Working</i><br></p>
  </blockquote>
  <p><strong>WORKING:</strong></p>
  <hr />
  <pre><code>#include &lt;iostream&gt;
  
  // Define is_palindrome() here:
  std::string is_palindrome(std::string text){
    std::string reverse= &quot;&quot;;
    for(int i=text.size()-1;i&gt;=0;i--){
      reverse += text[i];
    }
    if(reverse == text){
  
      return text + &quot; IS palindrome (reverse text: &quot; + reverse +&quot;)&quot;;
    } else {
  
      return text + &quot; NOT palindrome (reverse text: &quot; + reverse + &quot;)&quot;;
    }
  }
  
  int main() {
    
    std::cout &lt;&lt; is_palindrome(&quot;madam&quot;) &lt;&lt; &quot;\n&quot;;
    std::cout &lt;&lt; is_palindrome(&quot;ada&quot;) &lt;&lt; &quot;\n&quot;;
    std::cout &lt;&lt; is_palindrome(&quot;lovelace&quot;) &lt;&lt; &quot;\n&quot;;
    
  }
  </code></pre>
  <p><strong>output</strong></p>
  <pre><code>madam IS palindrome (reverse text: madam)
  ada IS palindrome (reverse text: ada)
  lovelace NOT palindrome (reverse text: ecalevol)
  </code></pre>
  <p><strong>NOT WORKING</strong></p>
  <pre><code>#include &lt;iostream&gt;
  
  // Define is_palindrome() here:
  std::string is_palindrome(std::string text){
    std::string reverse= &quot;&quot;;
    for(int i=text.size();i&gt;=-1;i--){
      reverse += text[i];
    }
    if(reverse == text){
  
      return text + &quot; IS palindrome (reverse text: &quot; + reverse +&quot;)&quot;;
    } else {
  
      return text + &quot; NOT palindrome (reverse text: &quot; + reverse + &quot;)&quot;;
    }
  }
  
  int main() {
  
    std::cout &lt;&lt; is_palindrome(&quot;madam&quot;) &lt;&lt; &quot;\n&quot;;
    std::cout &lt;&lt; is_palindrome(&quot;ada&quot;) &lt;&lt; &quot;\n&quot;;
    std::cout &lt;&lt; is_palindrome(&quot;lovelace&quot;) &lt;&lt; &quot;\n&quot;;
  
  }
  </code></pre>
  <p><strong>output</strong></p>
  <pre><code>madam NOT palindrome (reverse text: madam)
  ada NOT palindrome (reverse text: ada)
  lovelace NOT palindrome (reverse text: ecalevol)
  </code></pre>