I've managed to print left-aligned padded columns when the output is static like this:
int col = 40;
printf("%-*s", col, "padded column");
printf("after the column\n");
I'm trying to do the same when the string is not static but formatted with a variable, ie:
int col = 40;
int var1 = 200;
printf("???", col, var1, " padded column");
printf("after the column\n");
Where the expected output would be, for example:
200 padded column after padded column
%dnot good enough?printf("%-*s", col, "%d padded column", var1);is of course not valid, and thisprintf("%d%-*s", var1, col, " padded column");doesn't generate a total width ofcol.