c++consoleformattabular

Format output in a table, C++


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 in console app (C#)


Solution

  • 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: https://cplusplus.com/reference/cstdio/printf/