fill right side of stringstream variable with '0' c++
<p>I have the next code: </p>

<pre><code>ofstream dataIndex;
dataIndex.open("file");

index="2222";
std::stringstream sstr1;
sstr1&lt;&lt;index&lt;&lt;'1';
sstr1&lt;&lt;setfill('0')&lt;&lt;setw(index.length()-9);
string index1= sstr1.str();
dataIndex&lt;&lt;index1;

dataIndex.close()
</code></pre>

<p>and i hope the result:</p>

<pre><code>2222100000
</code></pre>

<p>but only i get</p>

<pre><code>22221
</code></pre>

<p>without zeros? what happened?</p>
