iterator is pointing to first element after a "find_if" match, why?
<p>I'm teaching myself c++ right now so I'm pretty new. One of the problem questions in the book I am learning from asks for a binary predicate that compares 2 strings. Below I've copied what I've written. I'm certain this is one of those really simple solutions, but I can't figure it out myself. Basically, my error is in the if statement. When there is a match, it always prints out the first element instead of the element where there was a match. Can you help explain why that is? What am I doing wrong? Also, as a newbie, I'd appreciate it if you see any 'ugly code' and can identify what you would write differently so that I can clean it up. Thanks!</p>

<pre><code>#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
#include &lt;string&gt;

using namespace std;

//my comparison predicate starts here

struct comparison{
    string deststring1;
    string deststring2;

comparison (const string&amp; whattheyenter){
    deststring1.resize(whattheyenter.size());
    transform(whattheyenter.begin(),whattheyenter.end(),deststring1.begin(),tolower);
    }

bool operator () (const string&amp; string2) {
    deststring2.resize(string2.size());
    transform(string2.begin(),string2.end(),deststring2.begin(),tolower);
    return (deststring1&lt;deststring2);
    }
};


  //program begins here

int main(){
    string comparethisstring;

    cout&lt;&lt;"enter string to compare: "&lt;&lt;endl;
    cin&gt;&gt;comparethisstring;

    vector&lt;string&gt; listofstrings;

    listofstrings.push_back("my fiRst string");
    listofstrings.push_back("mY sEcond striNg");
    listofstrings.push_back("My ThIrD StRiNg");

    auto ielement = find_if(listofstrings.begin(),listofstrings.end(),comparison(comparethisstring));

    if (ielement!=listofstrings.end()){
          // when there is a match this always prints "my fiRst string" instead of 
          // pointing to the element where the match is.
        cout&lt;&lt;"matched:" &lt;&lt;*ielement; 
    }
    else {
        cout&lt;&lt;"no match found!";
    }

return 0;
}
</code></pre>

<p>EDIT: Just wanted to say the issue was that first, I used a less than operator, which is no use for comparing equality. Second, I used cin instead of getline. As a result when I typed in "my first string" cin only assigned "my" to comparethisstring. Thanks everyone for the help!</p>
