0

In my C++ code, I want to generate my data (6 digits) as e.g. 4 columns. I'd like also to put the name of each variable on the first line. Here is the way that I do by aligning them with some try-error which is of course not the elegant and proper way:

out_file << "p_x   \t       p_y   \t    re_part   \t     calibrate" << endl;

out_file << p_x<<"\t"<<p_y<<"\t"<<real(beta)<<"\t"<<calib<<endl;

Q: How can I format them in a way that each name appear on top of the corresponding column? Thanks in advance!

physiker
  • 889
  • 3
  • 16
  • 30
  • 2
    Please see this post https://stackoverflow.com/questions/2485963/c-alignment-when-printing-cout – Cory Kramer Mar 05 '14 at 15:19
  • very useful link. How do I install boost? that seems the best (why is not an accepted answer? ) – physiker Mar 05 '14 at 15:23
  • if you would like to use the Boost solution, see their Getting Started page http://www.boost.org/doc/libs/1_55_0/more/getting_started/windows.html – Cory Kramer Mar 05 '14 at 15:29
  • I found a much easier solution ( not in c++). After having the data file, just in terminal: column -t filename – physiker Mar 05 '14 at 16:02

0 Answers0