allineing the output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthigeyantp
    New Member
    • Jul 2008
    • 22

    allineing the output

    Where i am developing a c++ program which has write a bulk of number in a file like this
    +990.789
    +678.980
    + 35.738 // Diff is here
    +678.908
    - 90.780 // diff is here
    how can i achive this. the length will be keeps on changing
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    Use format specifier like %7.3f

    Comment

    • archonmagnus
      New Member
      • Jun 2007
      • 113

      #3
      Since you are working with C++, I'd suggest looking into the inclusion of:

      [code=cpp]
      #include <iomanip>
      [/code]

      perhaps you'd be interested in using the functions from that library to handle your output alignment/formatting. Specifically the methods 'setw', 'setfill', 'setprecision', etc.

      See the reference here.

      Comment

      Working...