If I have two tables stored in std::string
variables, how could I display them side-by-side? In particular...
I have std::string table1
which contains the following:
X | Y
-------
2 | 3
1 | 3
5 | 2
I have std::string table2
which contains the following:
X | Y
-------
1 | 6
1 | 1
2 | 1
3 | 5
2 | 3
I need to modify them (or really just print them to standard output) so that the following appears:
X | Y X | Y
------- -------
2 | 3 1 | 6
1 | 3 1 | 1
5 | 2 2 | 1
3 | 5
2 | 3
In other words, I have two tables stored in std::string
variables with newline characters separating the rows.
I would like to print them to screen (using std::cout
) so that the tables appear side-by-side, vertically aligned at the top. How could I do this?
For example, if I could do something like std::cout << table1.nextToken('\n')
where nextToken('\n')
gives the next token and tokens are separated by the '\n'
character, then I could devise a method to cycle through all tokens, and once all of table1
tokens are used, I could then simply print space characters so that the remaining tokens of table2
are properly horizontally aligned. But, such a nextToken(std::string)
function does not exist --- I don't know of it, at least.