Zero Padding or Leading Zeros

liudr:
With sprintf in the blink example code, it compiles just fine without using any library. I think the library is already included by arduino by default.

That is correct, though in a somewhat circuitous manner.

main.cpp include WProgram.h (the sketch you create is automatically merged with main.cpp by the Arduino IDE)
WProgram includes from the AVR Libc library:
http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html
http://www.nongnu.org/avr-libc/user-manual/group__avr__string.html
http://www.nongnu.org/avr-libc/user-manual/group__avr__math.html

But also includes from the 'Arduino library', among other things, HardwareSerial.h
HardwareSerial.h includes Stream.h
Stream.h includes Print.h
And Print.h includes avr-libc: <stdio.h>: Standard IO facilities, which provides the various versions of printf.

It's all rather academic from the perspective of being able to use sprintf(), but it never hurts to have an understanding of what's going on beneath the covers, and I think it's always useful to know that the variety of C library functions in those modules are available for your usage within Arduino sketches by default.

1 Like