title: How can I output a nice neat column?
body: <p>I want the output format to align-right. My code is as follows.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  struct Planet
  {
      string name;
      double volume;
  };
  
  int main(int argc, const char * argv[]) {
      Planet planets[3]={{"太阳",22.1e20},{"地球",4.2e7},{"海王星",5.3e10}};
      for (int i=0; i&lt;3; i++)
      {
          cout&lt;&lt;right&lt;&lt;"\t"&lt;&lt;planets[i].name&lt;&lt;setw(12)&lt;&lt;planets[i].volume&lt;&lt;endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>When I run this code. The output is llike in the picture below, but it's not what I want. Because the output columns cannot align-right.</p>
  
  <p><a href="https://i.stack.imgur.com/LVyO4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LVyO4.png" alt="enter image description here"></a></p>