some help needed - formatting integer - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: some help needed - formatting integer (
/showthread.php?tid=257124)
some help needed - formatting integer -
KoczkaHUN - 24.05.2011
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
Re: some help needed - formatting integer -
leong124 - 24.05.2011
"%6d" will only leave blanks before the number when it's not big enough.
Try "%06d". This will fill the blanks with zeros.