title: C++ setup columns using cout
body: <p>So i'm just starting to learn c++ and i'm curious if its a way to formate your output with cout so it will look nicely and structured in columns</p>
  
  <p>for example.</p>
  
  <pre><code>string fname = "testname";
      string lname = "123";
      double height = 1.6;
  
      string fname2 = "short";
      string lname2 = "123";
      double height2 = 1.8;
  
      cout &lt;&lt; "Name" &lt;&lt; setw(30) &lt;&lt; "Height[m]" &lt;&lt; endl;
      cout &lt;&lt; fname + " " + lname &lt;&lt; right &lt;&lt; setw(20) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; height &lt;&lt; endl;
      cout &lt;&lt; fname2 + " " + lname2 &lt;&lt; right &lt;&lt; setw(20) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; height2 &lt;&lt; endl
  </code></pre>
  
  <p>The output looks like this:</p>
  
  <pre><code> Name                   Height[m]
   testname 123              1.60
   short 123              1.80
  </code></pre>
  
  <p>I want it to look like this:</p>
  
  <pre><code>Name                   Height[m]
  testname 123             1.60
  short 123                1.80
  </code></pre>
  
  <p>The problem i'm trying to solve is that i want to place height at a specific position from name but depending what length of name i take the value of height either gets far away to the right or will be very close to the left. Is there a way to fix this?</p>