Aligning Columns

This is a discussion on Aligning Columns within the C Programming forums, part of the General Programming Boards category; To create columns I use tab spacing in my printf's. When text in a column varies more than a little ...

  1. #1
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218

    Aligning Columns

    To create columns I use tab spacing in my printf's. When text in a column varies more than a little in length the alignment gets screwed up. Is there a simple way to fix this?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    check out the width sub-specifier

    http://www.cplusplus.com/reference/c...io/printf.html

    edit: I am also a little confused now that I think about it.
    Last edited by robwhit; 06-27-2007 at 09:21 AM.

  3. #3
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    Is this output-related or what you see in the source code? I don't really know what you mean.

  4. #4
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    check out the width sub-specifier
    Oh cool, thats easy. I guess I should have read a bit about printf. There is quite a bit more you can do with it than I thought.

    Is this output-related or what you see in the source code? I don't really know what you mean.
    Yeah its output related. Just the way the text was aligning when being printed in the console window.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Output Columns form a file
    By Cdrwolfe in forum Tech Board
    Replies: 2
    Last Post: 03-22-2006, 05:12 AM
  2. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 06:10 PM
  3. Program that prints numbers in columns
    By rayrayj52 in forum C++ Programming
    Replies: 12
    Last Post: 09-20-2004, 03:43 PM
  4. reading a columns input data file
    By vk13wp in forum C Programming
    Replies: 6
    Last Post: 04-28-2003, 02:32 PM
  5. Number of columns in ListControl
    By MPSoutine in forum Windows Programming
    Replies: 3
    Last Post: 03-28-2003, 02:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21