Formating output

This is a discussion on Formating output within the C Programming forums, part of the General Programming Boards category; Hey, I'm trying to make a nice looking output, but some of the information I'm outputting is too long. I ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    11

    Formating output

    Hey, I'm trying to make a nice looking output, but some of the information I'm outputting is too long. I know %8s will give you 8 characters minimum, but is there anyway to do a max?
    Never mind, got it here. Thanks anyway.
    Last edited by jrfall349; 04-25-2007 at 05:24 PM. Reason: Got it

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by jrfall349 View Post
    Hey, I'm trying to make a nice looking output, but some of the information I'm outputting is too long. I know %8s will give you 8 characters minimum, but is there anyway to do a max?
    Sure. Put a number immediately after the decimal point:

    printf("\n%15.12s", string), will give you a max of 12 char's output, in a 15 char wide field.

    In a number, the 12 shown above will give you a maximum of 12 digits after the decimal point.

    Edit: Too slow, foiled again.

    Adak

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 02:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 02:29 PM
  3. strange virtual function output
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 02-08-2008, 07:08 AM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 04:27 AM

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