How to format strings using printf() to get equal length in the output
printf
allows formatting with width specifiers. For example,
printf( "%-30s %s\n", "Starting initialization...", "Ok." );
You would use a negative width specifier to indicate left-justification because the default is to use right-justification.
You can specify a width on string fields, e.g.
printf("%-20s", "initialization...");
And then whatever's printed with that field will be blank-padded to the width you indicate.
The -
left-justifies your text in that field.