title: Assign a string from an iterator
body: <p>Here is a problem I have , I have a vector of filenames and I want to check if they end by .jpg or by .png so I made some code with iterators and the STL, this i also for creating a std::map with those names as keys and with value a texture, so here is my code, that does a Segmentation Fault error at the line 11:</p>
  
  <pre><code>#include "TextureManager.h"
  
  std::map&lt;std::string,sf::Texture&gt; createTextureArray(){
  std::map&lt;std::string,sf::Texture&gt; textureArray;
  
  std::vector&lt;std::string&gt;::iterator strIt;
  std::string fName;
  
  for(strIt = textureFileList().begin(); strIt != textureFileList().end(); strIt++){
      sf::Texture texture;
      fName = *strIt;
      if(fName[fName.size()] == 'g' &amp;&amp; fName[fName.size()-1] == 'p' &amp;&amp; fName[fName.size()-2] == 'j' &amp;&amp; fName[fName.size()-3] == '.'){
          texture.loadFromFile(fName);
          textureArray[fName] = texture;
      }
      else if(fName[fName.size()] == 'g' &amp;&amp; fName[fName.size()-1] == 'n' &amp;&amp; fName[fName.size()-2] == 'p' &amp;&amp; fName[fName.size()-3] == '.'){
          texture.loadFromFile(fName);
          textureArray[fName] = texture;
      }
  }
  return textureArray;
  }
  </code></pre>
  
  <p>I think this is the only code needed to try to understand the problem , but if anyone wants more of this code here is the <a href="https://github.com/traxys/TileWars" rel="nofollow">Github repo</a></p>