title: ostringstream SOMETIMES causes a crash
body: <p>So I wrote an implementation of an ArrayList over the summer, and I have a toString method within which I use an ostringstream object to tack on strings and then output them. </p>
  
  <p>the method is below:</p>
  
  <pre><code>template&lt;class T&gt;
  std::string ArrayList&lt;T&gt;::toString() {
  
      std::ostringstream streamOut;
  
      streamOut &lt;&lt; "(";
  
      for (int i = 0; i &lt; size; i++) {
  
          streamOut &lt;&lt; array[i];
  
          if (i != (size - 1)) {
  
              streamOut &lt;&lt; ", ";
          }
      }
  
      streamOut &lt;&lt; ")\n";
  
      std::string returnString = streamOut.str();
  
      return returnString;
  }
  </code></pre>
  
  <p>The problem is that when I run this program it sometimes crashes on the line in the above method: </p>
  
  <pre><code>    streamOut &lt;&lt; "(";
  </code></pre>
  
  <p>I tried adding a flush statement at the end but that didn't do the trick...I really have no idea what could be wrong here.</p>
  
  <p>I think this issue may be related but I can't be sure....</p>
  
  <p><a href="https://stackoverflow.com/questions/8250851/big-ostringstream-causes-application-crash">https://stackoverflow.com/questions/8250851/big-ostringstream-causes-application-crash</a></p>
  
  <p>EDIT:</p>
  
  <p>I forgot to mention, that I am using eclipse for development, and I have been unable to get a crash of the program to occur when I run it in eclipse. It's only when I run the exe generated via windows or the command line that it crashes</p>