Format output in a table, C++

前端 未结 4 1548
春和景丽
春和景丽 2020-12-09 20:30

How can I output data to the console in a table in C++? There\'s a question for this in C#, but I need it in C++.

This, except in C++: How To: Best way to draw table

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-09 21:03

    Can't you do something very similar to the C# example of:

    String.Format("|{0,5}|{1,5}|{2,5}|{3,5}|", arg0, arg1, arg2, arg3);
    

    Like:

    printf("|%5s|%5s|%5s|%5s|", arg0, arg1, arg2, arg3);
    

    Here's a reference I used to make this: http://www.cplusplus.com/reference/clibrary/cstdio/printf/

提交回复
热议问题