title: Setting width in C++ output stream
body: <p>I'm trying to create a neatly formatted table on C++ by setting the width of the different fields. I can use setw(n), doing something like</p>
  
  <pre><code>cout &lt;&lt; setw(10) &lt;&lt; x &lt;&lt; setw(10) &lt;&lt; y &lt;&lt; endl;
  </code></pre>
  
  <p>or change ios_base::width</p>
  
  <pre><code>cout.width (10);
  cout &lt;&lt; x;
  cout.width (10);
  cout &lt;&lt; y &lt;&lt; endl;
  </code></pre>
  
  <p>The problem is, neither of the alternatives allows me to set a default minimum width, and I have to change it everytime I'll write something to the stream.</p>
  
  <p>Does anybody knows a way I can do it without having to repeat the same call countless times?
  Thanks in advance.</p>