From: Glynn Clements <glynn.clements@virgin.net>
To: "J." <mailing-lists@xs4all.nl>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: printf(), aligning fields
Date: Sun, 24 Aug 2003 01:07:42 +0100 [thread overview]
Message-ID: <16200.462.367759.211524@cerise.nosuchdomain.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.21.0308232217220.23476-100000@hestia>
J. wrote:
> I am trying to print collums from a c program, as the
> following example illustrates:
>
> Total Number Folder
> ----- ------ ------
> 15502 17 cronlog
> 189897 42 linux/debian-curiosa
> 161751 32 linux/debian-firewall
> 4305 1 linux/debian-general
> 17431 1 linux/debian-news
> 107517 1 linux/vger-kernel-announce
> 61136 16 linux/vger-kernel-c-programming
> 8580 2 linux/vger-kernel-gcc
>
> How can I can align the output to the max right field boundry without
> overcrossing that field boundry if the field value gets longer?
>
> Do I really have to check the length of the value before printing it with,
> %*s, and then determine how many spaces I need?
You have to make the field large enough to hold all of the values. The
*printf() family of functions don't provide any way to truncate a
field to a maximum width.
--
Glynn Clements <glynn.clements@virgin.net>
next prev parent reply other threads:[~2003-08-24 0:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-21 12:48 Question about checksums Holger Kiehl
2003-08-21 13:20 ` Luciano Miguel Ferreira Rocha
2003-08-21 16:36 ` Holger Kiehl
2003-08-21 17:28 ` Jeff Woods
2003-08-22 20:18 ` Holger Kiehl
2003-08-23 20:31 ` printf(), aligning fields J.
2003-08-24 0:07 ` Glynn Clements [this message]
2003-08-24 1:05 ` Stephen Satchell
2003-08-21 18:19 ` Question about checksums Luciano Miguel Ferreira Rocha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16200.462.367759.211524@cerise.nosuchdomain.co.uk \
--to=glynn.clements@virgin.net \
--cc=linux-c-programming@vger.kernel.org \
--cc=mailing-lists@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).