Key words: istringstream, getline
Implementaion:
#include <iostream>
#include <sstream>
int main()
{
std::string table1 =
" X | Y\n"
"-------\n"
" 2 | 3\n"
" 1 | 3\n"
" 5 | 2\n";
std::string table2 =
" X | Y\n"
"-------\n"
" 1 | 6\n"
" 1 | 1\n"
" 2 | 1\n"
" 3 | 5\n"
" 2 | 3\n";
std::istringstream streamTable1(table1);
std::istringstream streamTable2(table2);
while (!streamTable1.eof() || !streamTable2.eof())
{
std::string s1;
getline(streamTable1, s1);
while (s1.size() < 9)
s1 += " ";
std::string s2;
getline(streamTable2, s2);
std::cout << s1 << s2 << std::endl;
}
}