title: stringstream and for loop
body: <p>I'm using a stringstream to generate "dynamically", the name of the files I need to open and this is my  code:</p>
  
  <pre><code>for (int img=0; img&lt;5; img++)
  {
  stringstream stream;
  string *s=new string("myfile");
  stream &lt;&lt; img &lt;&lt; ".png"
  s-&gt;append(stream.str());
  
  .. other code
  </code></pre>
  
  <p>the problem is than the first time the program flows into the loop it works fine, the second time stream does not has the value "1.png", but has value null... so when I try to open the file I get a null pointer.</p>
  
  <p>ho do I fix this?</p>