title: Map in C++ give the key and get the string
body: <p>I have <strong><em>created a map</em></strong> like this :   <code>std::map&lt;int, std::string&gt; mapID;</code></p>
  
  <p><strong><em>INPUT:</em></strong> mapID[1] = "string!"; </p>
  
  <p>and I want to print element with the key is the s. 
  For example   </p>
  
  <pre><code>cout &lt;&lt; "The string is : " &lt;&lt; mapID.at(s)-&gt;second &lt;&lt; endl;
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>cout &lt;&lt; "The string is : " &lt;&lt; mapID.find(s)-&gt;second &lt;&lt; endl;
  </code></pre>
  
  <p>But I have the error </p>
  
  <blockquote>
    <p>error: no matching function for call to ‘std::map >::at(std::string&amp;)’ </p>
  </blockquote>
  
  <p><strong><em>UPDATE:</em></strong> </p>
  
  <pre><code>while(getline(file,s)) 
                     {
                             cout&lt;&lt; s &lt;&lt; endl;
                             number = atoi(s.c_str());
  
                           cout &lt;&lt; "The string is: " &lt;&lt; mapID.at(number)&lt;&lt; endl;
  }
  </code></pre>