We all know in C-based languages, printf("%11d", some_int); means right align within an 11 character field, but what if I want to replace this constant 11 here with a dynamic variable, what am I gonna do ?
You can use the *
character to specify the field width in its own argument:
printf("%*d", some_width, some_int);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With