Thread: right justifying??

  1. #16
    Registered User
    Join Date
    Apr 2002
    Posts
    15
    This is part of the code, just imagine it reading records from the file and printing it down the page all right justified so the pennies are in the same columns, cheers.

    fprintf(pp, " %s %d %4d %4d %d %3.1f %4.2f %3.1f %4.2f\n", reference_no, type_code,
    weight, quantity, calc_method, buy_price, buy_value, sale_price, sale_value);

  2. #17
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    %4.2f means 4 wide. If you have 150.00, thats 5 wide. Make the width bigger, like %8.2f
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #18
    Registered User
    Join Date
    Apr 2002
    Posts
    15
    Cheers Hammer, i can see what that is doing, Its gonna be a great help.

    Thanks again. Bye for know. Ganonshin.

  4. #19
    sodsm live
    Guest
    hmm, I guess I completely misunderstood the problem, sorry for any confusion I may have caused

  5. #20
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by sodsm live
    hmm, I guess I completely misunderstood the problem, sorry for any confusion I may have caused
    I read ya post, and no, I don't think it was wrong! You pointed out the same as me, only adding the padding with zeros bit.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. right justifying numbers
    By arya6000 in forum C Programming
    Replies: 1
    Last Post: 11-26-2007, 05:14 PM
  2. String Justifying
    By m0ntana in forum C Programming
    Replies: 11
    Last Post: 04-09-2007, 03:24 PM
  3. justifying text
    By a.baki in forum C Programming
    Replies: 10
    Last Post: 04-20-2006, 02:36 PM
  4. Justifying text with strings
    By edwardvgrant in forum C Programming
    Replies: 6
    Last Post: 04-24-2004, 08:16 AM
  5. Right Justifying output
    By alpha in forum C++ Programming
    Replies: 5
    Last Post: 10-10-2003, 04:56 PM