How do I correctly organize output into columns?

前端 未结 5 994
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 04:58

The first thing that comes to my mind is to do a bunch of \\t\'s, but that would cause words to be misaligned if any word is longer than any other word by a few characters.<

5条回答
  •  醉梦人生
    2020-12-08 05:40

    Use string formatting (from stdio) to display each line.

    http://www.cppreference.com/wiki/c/io/printf

    It'll let you set minimum field widths and so it will pad the rest of each field for you.

提交回复
热议问题