fprintf help ,my print outs wont line up

This is a discussion on fprintf help ,my print outs wont line up within the C Programming forums, part of the General Programming Boards category; I need some tricks. I'm a student and I cant get the output of my C programs to line up ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    9

    Unhappy fprintf help ,my print outs wont line up

    I need some tricks. I'm a student and I cant get the output of my C programs to line up in colunms.
    Using Turbo C and a dot matrix printer.

  2. #2
    Anti-Terrorist
    Join Date
    Aug 2001
    Location
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    Posts
    742
    This can sometimes be tricky. I would try printing out the table or whatever the output is to 'standard output' stdout first. That way you can see what it looks like in the console window. You can use tabs \t and I think backspaces \b to try to line up the columns. You can also try to incorporate column widths like so %20s in the format string.
    I compile code with:
    Visual Studio.NET beta2

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    27
    While you can use formating features such as /n /b and /t

    You can also format how much space between screen imput etc.. is displayed, these are called field Width specifiers..

    i.e
    ^ denotes a space

    printf("%d", 12345 ) Output = 12345
    printf("%2d", 12345 ) Output = 12345
    printf("%8d", 12345 ) Output = ^^^12345
    printf("%08d", 12345 ) Output = 00012345
    printf("%-2d", 12345 ) Output = 12345
    printf("%-10f", 3.8) Output = 3.800000^^
    printf("%-10.3d", 3.8) Output = 3.800^^^^^^

    Hope this helps.
    -ali

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do encryption in C
    By sankarv in forum C Programming
    Replies: 33
    Last Post: 12-28-2010, 10:01 AM
  2. Print Certain Line in C
    By mancode1009 in forum C Programming
    Replies: 7
    Last Post: 08-27-2008, 07:47 PM
  3. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 05:04 AM
  4. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 03:53 PM
  5. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 05:21 PM

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