Comparison of strings shows not equal
<p>I'm learning C++, and one of the exercices (Accelerated c++) is to code a small program which finds palindromes.</p>

<p>To do this, I've created a vector holding a few words, and I'm then iterating over this vector to find palindromes.
While iterating, I'm creating a copy of each word, reversing it, and then comparing if the reversed copy matches the origin word.</p>

<pre><code>using namespace std;
vector&lt;string&gt; palindrome(vector&lt;string&gt; v){
  for(std::vector&lt;string&gt;::iterator iter = v.begin(); iter != v.end(); ++iter){
    string reversed_word;
    for(int i = iter-&gt;size(); i &gt;= 0; i--){
      reversed_word += (*iter)[i];
    }
    if (!(*iter).compare(reversed_word)){
      cout &lt;&lt; reversed_word &lt;&lt; endl;
    }
    cout &lt;&lt; reversed_word &lt;&lt; endl;
    cout &lt;&lt; *iter &lt;&lt; endl;
  }
 return v
}


int main(){
  vector&lt;string&gt; dictionnary;
  dictionnary.push_back("coloc");
  dictionnary.push_back("elle");
  dictionnary.push_back("php");
  dictionnary.push_back("shahs");
  dictionnary.push_back("bonjour");
  dictionnary.push_back("random");

  palindrome(dictionnary);
  return 0;
}
</code></pre>

<p>However, the condition <code>!(*iter).compare(reversed_word)</code> doens't return what's expected for words that are palindromes. To check, I've displayed the words and the reverse words, and they do match.</p>

<p>What am I missing here ?</p>