title: c++ compare vector<string> x to string s
body: <p>I am trying to compare a string in a vector to another string:</p>
  
  <p>I tried:</p>
  
  <pre><code>vector&lt;string&gt; x;
  string y;
  
  if(x[i] == y)
  if(x[i].compare(y) == 0)
  if(y.compare(x[i]) == 0)
  if(x.at(i) == y)
  if(x.at(i).compare(y) == 0)
  if(y.compare(x.at(i)) == 0)
  </code></pre>
  
  <p>tried passing <code>x[i]</code> / <code>x.at(i)</code> to <code>string z</code> first, nothing. I get no compile errors, no problems, it just seems the vector at index i does not want to compare?</p>
  
  <pre><code>g++ -v 4.9.3
  Windows 7: cygwin64
  c++11, compiling using the -std=c++11 call
  </code></pre>
  
  <p>I print both strings out, they are identical, but it does not want to compare them.</p>
  
  <p>------- source cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  vector&lt;string&gt; get_file(const char* file){
        int SIZE=256, ln=0;
        char str[SIZE];
        vector&lt;string&gt; strs;
        ifstream in(file, ios::in);
        if(!in){
          return strs;
        } else {
          while(in.getline(str,SIZE)){
            strs.push_back(string(str));
            ln++;
          }
        }
        in.close();
        return strs;
      }
  
  void convert_file(const char* file){
        vector&lt;string&gt; s = get_file(file);
  
        vector&lt;string&gt; d;
        int a, b;
        bool t = false;
        for(int i=0; i&lt;s.size(); i++){
          string comp = "--";
          string m = s.at(i);
          cout &lt;&lt; m &lt;&lt; endl;
          if(m == comp){  //test string compare
            cout &lt;&lt; "s[i] == '--'" &lt;&lt; endl;
          }
        }
      }
  
  int main(){
    convert_file("dvds.txt");
    return 0;
  }
  </code></pre>
  
  <p>----- dvds.txt</p>
  
  <pre><code>--
  title:The Shawshank Redemption
  director:Stephan King
  release_date:14-10-1994
  actors:Tim Robbins,Morgan Freeman,Bob Guton
  genres:Crime,Drama
  rating:R
  price:4.99
  
  --
  title:Test title
  director:Stephan King
  release_date:10-10-1990
  actors:Morgan Freeman,random 2,random 4
  genres:Adventure,Comedy
  rating:PG-13
  price:4.99
  
  
  
  --
  title:Test 3
  director:None
  release_date:15-52-516
  actors:Tim Robbins,None,None 2
  genres:Crime,Comedy
  rating:PG-17
  price:4.99
  --
  </code></pre>
  
  <p>---- running</p>
  
  <pre><code>C:\drew\projects&gt;g++ -o a -std=c++11 source.cpp
  C:\drew\projects&gt;a
  </code></pre>
  
  <hr>
  
  <p>prints out the dvds.txt just fine, but no comparison is being done when it should</p>