3 Replies - 601 Views - Last Post: 22 September 2010 - 06:03 PM Rate Topic: -----

#1 vash370  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-September 10

setting number width?

Posted 22 September 2010 - 04:33 PM

Hi,

My question is on how to format the program so that the numbers it outputs are all the same width.

My main question would be how to make single digit number line up with double digit numbers.

Set example being letting 9.00 turn into 09.00

Sorry for the Uber-simple question, I just couldn't find this answer anywhere else because I kept getting the same field-width results.

Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: setting number width?

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3028
  • View blog
  • Posts: 10,547
  • Joined: 08-August 08

Re: setting number width?

Posted 22 September 2010 - 04:46 PM

Use printf()
Was This Post Helpful? 0
  • +
  • -

#3 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: setting number width?

Posted 22 September 2010 - 04:46 PM

Have a look at Set field width which is a part of Stream manipulators
Was This Post Helpful? 1
  • +
  • -

#4 anonymouscodder  Icon User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: setting number width?

Posted 22 September 2010 - 06:03 PM

printf ("Try me: %05.2f \n", 9.0);


http://www.cplusplus.../cstdio/printf/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1