Hi all,
I was annoyed by necessity to use sprintf(buffer...) xxx.print(buffer), when I wanted to have especially digits to have correctly formatted. As many of .print functions (serial, lcd etc.) inherit from print library, I modified the print library with another parameter, which allows (at all unsigned types-i.e. char, int, long) to print with fixed numer of digits and selectable prefix character. For example,
lcd.print((unsigned)i, DEC, FILL_ZEROS | 5);
if i is 123, for example, the printed output will be 00123. If the third parameter is omitted, is behaves like a standard print library included with IDE. Other option is FILL_SPACES.
You can use either FILL_SPACES or FILL_ZEROS. As for the footprint, when I recompiled my sketch with change from sprintf(buffer...) to my mod print lib, the sketch went from approx. 4k to approx. 3k. Except of passing one more parameter to the function call, there is almost none performance penalty. The change is surprisingly small. You can look at the source code and try the modified and unmodified library, the sources are available.