title: How to use map::end from map::find in C++
body: <p>I want to use the C++ map function, <a href="http://www.cplusplus.com/reference/stl/map/find/" rel="nofollow">map::find</a>, to determine if a specific string is within a map. I know that find returns <code>map::end</code> but I am not sure on how to use it. So if the same string exists in both <code>names_</code> and <code>info_</code>, I want it to print that string to the screen.</p>
  
  <p>In my header:</p>
  
  <pre><code>std::vector&lt;std::string&gt;names_;
  std::map&lt;std::string, unsigned int&gt; info_;
  </code></pre>
  
  <p>In the .cpp (THIS CODE IS WRONG):</p>
  
  <pre><code>for(unsigned int i=0;i&lt;names_.size();i++){
      std::map&lt;std::string, unsigned int&gt;::iterator it;
      it = info_.find(names_[i]);
      if info_.find(names_[i]) != info_.end()
          std::cout &lt;&lt; names_[i] &lt;&lt; std::endl; 
  }
  </code></pre>
  
  <p>What I am doing wrong in the .cpp code snipet? I know it is something with iterators. </p>