some help needed - formatting integer
#1

Hello all,
I want to format an integer to a string by filling the number with zeros if it's not enough big, like: "000015" or "012345"
I tried to do this:
pawn Код:
format(tdstr, sizeof(tdstr), "%6d", floatround(newval, floatround_floor));
but this does not seem to work.. can I do it somehow without a lot of conditional (even if they're shorthand) or do I need to create a function that returns a formatted string from the integer?
A bit help would be great,

Thanks
Reply
#2

"%6d" will only leave blanks before the number when it's not big enough.
Try "%06d". This will fill the blanks with zeros.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)