Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2004
    Posts
    109
    Thanks
    5
    Thanked 0 Times in 0 Posts

    aranging C prog output into columns

    hey there, i'm currently trying to produce a program and output data in the following format:



    apparently i have to get the output as close to that as possible, but i don't know any other ways of printing stuff out other than just text and spaces, or using \t, but if i use either of those then whenever the length of a bane ir weight changes then the text to the right of it is gonna get unaligned.

    the best way i can think of is counting the words/numbers in one bit of data (name/weight) then adding the correct number of spaces after it to line the following data up.

    is there any easier way of laying stuff out like in the example?

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use formatting identifiers in printf (check out the minimum field width). If you're using C++'s cout there is something similar for it too.

    shmoove

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    109
    Thanks
    5
    Thanked 0 Times in 0 Posts
    thanks, that works great a center align would be nice though


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •