title: Can anyone check if this Palindrome c++ code is correct?
body: <p>Here is a program i built to check palindrome words in c++. It does not work in usual way (to reverse the word and check if its same), but it directly checks each word from start and end; </p>
  
  <p>madam, ada, hannah, racecar are the words i have tried and they seem to be correct.</p>
  
  <pre><code>    #include &lt;iostream&gt;
  
  std::string is_palindrome(std::string text)
  {
    int length=text.size();     //No. of characters
    int index=text.size()-1;    //No. of indexes
    int i;
    int x=0;                 //To store no of same character from both ends
    for(i=0;i&lt;=index;i++)
    {
         if(text[i]==text[index-i])
       {x++;}
    }
    if(x==length)             //If all characters are same form opp ends
    {
      return "true";
    }
    else
    {
      return "false";
    }
  }
  
  int main() {
  
    std::cout &lt;&lt; is_palindrome("madam") &lt;&lt; "\n";
    std::cout &lt;&lt; is_palindrome("happy") &lt;&lt; "\n";
  
  }
  
  </code></pre>
  
  <p>The results are correct, i just could not find a code like this, so just wanted to check it.</p>