From Progzoo
Jump to navigation Jump to search

You can format numbers using the % operator. See Format Printing for details of some other options that are available.

You can build a string using the % operator. The %8d place holder will ensure that the number takes exactly 8 spaces.

If you need to provide more than one argument on the right side, then they will need to be grouped into an array.

The output with "Number:%8d" prints a decimal in 8 spaces:

Number:   12345

[Font] [Default] [Show] [Resize] [History] [Profile]