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

后端 未结 6 1653
一个人的身影
一个人的身影 2020-11-28 05:10

I have two functions, one which produces messages like Starting initialization... and another which checks return codes and outputs \"Ok\", \

6条回答
  •  天涯浪人
    2020-11-28 06:00

    Start with the use of Tabs, the \t character modifier. It will advance to a fixed location (columns, terminal lingo). However, it doesn't help if there are differences of more than the column width (4 characters, if I recall correctly).

    To fix that, write your "OK/NOK" stuff using fixed number of Tabs (5? 6?, try it), then return (\r) without new-lining, and write your message.

提交回复
热议问题