How can I use a macro in padding a number in C?

c

Solution

Use the `*` format specifier to pass the width as argument. Something like this should work:

sprintf( Formatted, "%0*d", MACR, Number );

But please use a constant not a MACRO.

Problem

I am trying to use a macro in sprintf statement. It is like this : ``` #define MACR 6 .... int Number= 5; char Formatted[30]; sprintf( Formatted, "%06d", Number ); ``` Here I would like to use MACR instead of 6. Can anyone help me please?

Original source