title: c++ stringstream not working properly when changing integer to string
body: <p>I am trying to make a function that will create folders for me and name them using a combination of numbers. Here is the code I made for the function:</p>
  
  <pre><code>void folderMaker(int xCount, int yCount)
  {
    stringstream ssObject;
    string xString;
    string yString;
  
    for (int x = 0; x&lt;xCount; x++)
    {
      for (int y = 0; y&lt;yCount; y++)
      {
        ssObject &lt;&lt; x;
        xString = ssObject.str();
  
  
        ssObject &lt;&lt; y;
        yString = ssObject.str();
  
        string nameAndLocation = "C:\\User\\DestinationFolder\\" + xString + "and" + yString;
        CreateDirectory (nameAndLocation.c_str(), NULL);
  
      }
    }
  }
  </code></pre>
  
  <p>I want to make the two "for" loops give certain values to the x and y variables. From there I want to make the name of the new folder created with those two variables included in the name. For that reason I use the ssObject I created. The result is that I do in fact make the folders I want, however the names are not the names I wanted. For instance, if xCount = 3 and yCount = 1, I get the following folder names:</p>
  
  <p>name of first folder: x0andy00</p>
  
  <p>name of second folder: x001andy0010</p>
  
  <p>name of third folder: x00102andy001020</p>
  
  <p>Why am I getting those names (instead of x0andy0, x1andy0, and x2andy0 in the case of xCount = 3 and yCount = 1)? and how might I go about getting the proper result that I want?</p>