sprintf(str,"%07d",3); results in "0000003"
sprintf(str,"%7d",3); results in " 3"
sprintf(str,"%d",3); results in "3"
But Huskers isn't using a width format specifier in his sprintf statement. It looks like He's starting with an empty string:
""
then basically concatenating the next value using sprintf:
1st loop: "0"
2nd loop: "00"
3rd loop: "000"
4th loop: "0000"
5th loop: "00004"
.
.
.
finally: "0000418.23"
(I'm still not sure where the decimal is coming from, but that's irrelevant)
The result is a numeric string with leading 0's that need to be stripped off.
Consider Eliminating the source of the leading 0's as ArkM suggested or something like I suggested earlier. There are, of course other ways to do the same thing.
Also, mingis pointed out some problems with the code.
Good luck.