Become a MacRumors Supporter for $25/year with no ads, private forums, and more!

Mac what does printf("%2d",x) mean

dukebound85

macrumors P6
Original poster
Jul 17, 2005
18,271
2,170
5045 feet above sea level
i know what everything in the function does except for the 2. what exactly does the 2 do when printing the integer to the screen?
i know with a float, it contols the decimal places but with an integer i have no idea

or a 3? i have seen %3d as well while i am studying for my exam tomorrow


thanks!
 

balamw

Moderator
Staff member
Aug 16, 2005
19,366
978
New England
man printf

An optional decimal digit string specifying a minimum field width.
If the converted value has fewer characters than the field width, it
will be padded with spaces on the left (or right, if the left-adjust-
ment flag has been given) to fill out the field width.

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.