How to format strings using printf() to get equal length in the output

Viewed 173904

I have two functions, one which produces messages like Starting initialization... and another which checks return codes and outputs "Ok", "Warning" or "Error". However, the output that is produced is of the different length:

Starting initialization...Ok.
Checking init scripts...Ok.

How can I get something like the following?

Starting initialization...       Ok.
Checking init scripts...         Ok.
6 Answers
Related