my question is simple. I want to print integers with a specified amount of leading zeros, using printf. However, the number of leading zeros is decided runtime, not known a priori. How could I do that?
If I knew the number of characters (let’s say 5), it would be
printf("%05d", number);
But I don’t know if it will be 5.
You can pass a width using
*: