title: How do I use iomanip's setw, setfill, and left/right? Setfill isn't stopping its output
body: <p>I'm trying to get my output to look like this:</p>
  
  <pre><code>size       time1       time2
  -------------------------------
  10         4           8
  100        48          16
  1000       2937        922
  10000      123011      3902
  100000     22407380    830722
  </code></pre>
  
  <p>And I know I need to use <code>setw()</code>, <code>setfill()</code>, and <code>left</code>. However, my attempts keep giving me incorrect output. Here is one example of my code:</p>
  
  <pre><code>std::cout &lt;&lt; "size" &lt;&lt; std::setw(20) &lt;&lt; "time" &lt;&lt; std::setw(20) &lt;&lt; "time2\n";
  std::cout &lt;&lt; std::setfill('-') &lt;&lt; std::setw(60) &lt;&lt; "-" &lt;&lt; std::endl;
  run = 10;
  for(int i = 0; i &lt; 5; i++) {
      std::cout &lt;&lt; run;
      run *= 10;
      std::cout &lt;&lt; std::setw(20) &lt;&lt; std::left &lt;&lt; time1[i];
      std::cout &lt;&lt; std::setw(20) &lt;&lt; std::left &lt;&lt; time2[i] &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>And here's the output:</p>
  
  <pre><code>size    time1    time2
  ------------------------------------------------------------
  103-------------------13------------------
  100171-----------------199-----------------
  100013183---------------667-----------------
  10000670130--------------8205----------------
  10000014030798-------------1403079888---------
  </code></pre>
  
  <p>I've tried changing the order that I'm using <code>setw()</code>, <code>setfill()</code>, and <code>left</code>, but I'm just flying blind right now. I've also searched iomanip tutorials. I'm following the directions--as far as I can tell--but I'm still not getting it.</p>
  
  <p>How do I stop the <code>setfill()</code> from running over? How do I justify left but use <code>setw()</code> to stop the numbers from running into each other?</p>