In the second case the sprintf statement is taken as the argument of the print statement, so the statement as a whole concatenates the result of print with the string "hello\n" and prints 00001 as a side effect.
will do what you want.print((sprintf "%5.5d", 1) . "hello\n");
Incidently, I'd use %05d as a formatting string: this is compatible with C, yours isn't if memory serves (and it doesn't really make sense if you think of it).
Hope this helps, -gjb-
In reply to Re: sprintf minor problem
by gjb
in thread sprintf minor problem
by Melly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |