fprintf woes...

This is a discussion on fprintf woes... within the C Programming forums, part of the General Programming Boards category; I am printing to a file and have the following problem that I can't seem to fix. When I print ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    23

    fprintf woes...

    I am printing to a file and have the following problem that I can't seem to fix. When I print out the results the last two fields are skewed because of the differnet lengths of the names that get printed unter the column header "Name".

    Here is the format that I am using:
    Code:
    fprintf(f," %i TIME        %s.00       1.000      %s           0.0000E+00  1.000\n", line_number, delay, name);
    Where: line_number is an integer, delay is a string, and name is a string.

    My results are attached. Please see the file called results.txt
    Attached Files Attached Files

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    for your %s, you can use %-Xs where X is some number (the number of cols you want the info to exist in) and the - is left justify.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    23
    Kennedy thanks! That worked.
    vic

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 03:19 PM
  2. program not working...please look at this
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 01-30-2006, 09:33 PM
  3. sprintf and fprintf segmentation error
    By kona1 in forum C Programming
    Replies: 5
    Last Post: 06-21-2005, 10:55 AM
  4. fprintf to stderr crash programs
    By jlai in forum Windows Programming
    Replies: 2
    Last Post: 04-12-2005, 08:51 AM
  5. fprintf
    By bennyandthejets in forum Windows Programming
    Replies: 10
    Last Post: 11-16-2002, 05:58 PM

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