Linux-Kernel-Internals - Linux Kernel Internals: https://ankitkdev.com/blog/ - Char Driver: https://ankitkdev.com/blog/linux-kernel/device-driver/char-driver/ - fasync Method: https://ankitkdev.com/blog/linux-kernel/device-driver/fasync/ - Ioctl Interface: https://ankitkdev.com/blog/linux-kernel/device-driver/ioctl/ - Poll Method: https://ankitkdev.com/blog/linux-kernel/device-driver/poll/ - Proc-Interface: https://ankitkdev.com/blog/linux-kernel/device-driver/proc/ - Completion-Variable: https://ankitkdev.com/blog/linux-kernel/deferred-work/completion-variable/ - Tasklet: https://ankitkdev.com/blog/linux-kernel/deferred-work/tasklet/ - Timers: https://ankitkdev.com/blog/linux-kernel/deferred-work/timer/ - Wait Queue: https://ankitkdev.com/blog/linux-kernel/deferred-work/wait-queue/ - container_of(): https://ankitkdev.com/blog/linux-kernel/macros/container_of/ - Debugging Macros: https://ankitkdev.com/blog/linux-kernel/macros/debug/ - Module Parameters: https://ankitkdev.com/blog/linux-kernel/macros/kernel-module/ - pr_fmt(): https://ankitkdev.com/blog/linux-kernel/macros/pr-family/ - Stringification: https://ankitkdev.com/blog/linux-kernel/macros/string/ - Error Handling with Pointers: https://ankitkdev.com/blog/kernal-internals/error-handling/ - Kbuild Makefile: https://ankitkdev.com/blog/kernal-internals/kbuild/ - SLUB debug: https://ankitkdev.com/blog/kernel-debugging/debug-slub-memory/ - C Memory Layout: https://ankitkdev.com/blog/c/c-memory-layout/ - do { ... } while (0): https://ankitkdev.com/blog/c/do-while-loop/ - Error Handling: https://ankitkdev.com/blog/c/error-handling/ - Forward Declarations: https://ankitkdev.com/blog/c/forward-declaration-in-c/ - Return value by Macro: https://ankitkdev.com/blog/c/return-by-macro/ - unsigned :\ 0 Bit-Fields in c: https://ankitkdev.com/blog/c/zero-width-bit-field/ - Variadic Macro: https://ankitkdev.com/blog/c/variadic-macro/ - Zero Padding in C: https://ankitkdev.com/blog/c/padding/ - programming concepts: https://ankitkdev.com/blog/theory/ - Build & Install Linux Kernel for BBB: https://ankitkdev.com/blog/misc/build-linux-kernel-BBB/ - Configure U-boot for BBB: https://ankitkdev.com/blog/misc/configure-uboot-bbb/ - Install Ubuntu Server on Qemu: https://ankitkdev.com/blog/misc/install-ubuntu-server-on-qemu/ - Linux Kernel Mentorship Program: https://ankitkdev.com/blog/misc/linux-kernel-mentorship-program/ - Reverse-Engineer apk/apks files: https://ankitkdev.com/blog/misc/debug-apk/ # Zero Padding in C with `printf` In C, `printf()` can add leading zeros to make a number occupy a fixed minimum width. The syntax is: ```c %0 ``` For example: ```c printf("%06d", 123); ``` Output: ```text 000123 ``` Here: * `0` → pad with zeros * `6` → minimum field width is 6 characters * `d` → print a signed decimal integer ### Zero padding vs space padding ```c printf("%06d", 123); ``` Output: ```text 000123 ``` while: ```c printf("%6d", 123); ``` Output: ```text 123 ``` So: ```text %06d → zero padding %6d → space padding ``` ### Example: hexadecimal ```c printf("0x%08lx\n", value); ``` For: ```c value = 0x1234; ``` the output is: ```text 0x00001234 ``` `%08lx` means: * `0` → zero padding * `8` → minimum width of 8 characters * `l` → `long` * `x` → hexadecimal Zero padding is useful when displaying **IDs, hexadecimal values, timestamps, counters, or other fixed-width numbers** where aligned output is desirable.