This doesn't do any error checking, but it does read the data:
#include <iostream> #include <fstream> #include <string> #include <vector> struct row_t { std::string x, y, z; }; std::vector<row_t> table; int main() { std::ifstream inputFile("data.txt"); row_t row; while (inputFile >> row.x >> row.y >> row.z) table.push_back(row); for(const row_t& row : table) std::cout << row.x << " " << row.y << " " << row.z << "\n"; return 0; } |