Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > printf() formatting - stripping zeroes, padding

Reply
Thread Tools

printf() formatting - stripping zeroes, padding

 
 
Michal Prinke
Guest
Posts: n/a
 
      10-19-2004
Hello,

Here are two questions on formatting values using printf():

1. How to strip trailing zeroes from float values?
printf("%f %f", 1.777, 1.2) displays "1.777000 1.200000",
while I want to have "1.777 1.2", without loosing 6-digit
precision.

2. Is it possible to pad values with other characters than
space and zero? printf(">%5s<", "abc") displays "> abc<".
I would like to have e.g. ">##abc<" or ">--abc<".

Thank you!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printf() formatting - stripping zeroes, padding Piotr B. C Programming 4 10-20-2004 12:55 PM
printf() formatting - stripping zeroes, padding Piotr B. C++ 2 10-19-2004 07:29 PM
printf() formatting - stripping zeroes, padding Michal Prinke C Programming 0 10-19-2004 03:28 PM
Need formatting options menu for formatting hard drive Mark T. Computer Support 3 11-24-2003 11:50 PM
regex for stripping HTML Michael Vilain Perl 4 10-30-2003 01:06 PM



Advertisments