Aligning fprintf

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • odin607
    New Member
    • Jun 2008
    • 19

    Aligning fprintf

    How can I have this align better. Not sure how to go about this since the lengths of the item names changes, the quantity changes (first number), and cost (second number) changes

    And ya, the items are from FFXI if anyone recognizes them.

    Code:
    This is one of my files being written to
    
             Bottom is most recent
           =========================
    One_Bynebill     5                30000gil   Mon Jul 21 02:31:30 2008
    Ordelle_Bronzepiece     1                 8000gil   Mon Jul 21 02:31:30 2008
    Montiont_Silverpiece     5              4000000gil   Mon Jul 21 02:33:04 2008
    Hundred_Bynebill     6              3600000gil   Mon Jul 21 02:33:04 2008
    Montiont_Silverpiece     2              1600000gil   Mon Jul 21 02:34:22 2008
    One_Bynebill     4                24000gil   Mon Jul 21 02:34:46 2008
    Montiont_Silverpiece     8              6400000gil   Mon Jul 21 02:35:46 2008
    T_Whiteshell    54               378000gil   Mon Jul 21 02:37:58 2008
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    If you google for printf formats (or check your reference book) you will find that the format specifiers (%s, %d, %f etc) can have field widths and precisions in them.

    Use of the field width (and possibly left aligning it) will allow you to get a more tabulated output.

    Comment

    Working...