printf() seems to align strings to the right.
printf("%10s %20s %20s\n", "col1", "col2", "col3"); /* col1 col2 col3 */
I can also align text to the left like this:
printf("%-10s %-20s %-20s", "col1", "col2", "col3");
Is there a quick way to center text? Or do I have to write a function that turns a string like
(space)(space)test(space)(space) if the text width for that column is 8?
© Stack Overflow or respective owner