printf add leading 0 code example Example: print number with leading zeros int n = 123; printf("%0.5d", n); // 00123