fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. std::vector<std::vector<std::string>> readTable(std::istream & is)
  7. {
  8. std::vector<std::vector<std::string>> table;
  9.  
  10. while ( is )
  11. {
  12. std::vector<std::string> line;
  13. for(std::size_t i = 0; i < 4+1; ++i) // vllt auch ohne +1, je nachdem ob mit oder ohne erste Spalte
  14. {
  15. std::string col;
  16. if ( std::getline(is, col, ';') )
  17. {
  18. line.push_back(col);
  19. }
  20. }
  21. table.push_back(line);
  22. }
  23.  
  24. return table;
  25. }
  26.  
  27. int main()
  28. {
  29. //std::ifstream file("myTable.txt");
  30. auto table = readTable(std::cin);
  31.  
  32. for(auto const& line : table)
  33. {
  34. for(auto const& element : line)
  35. {
  36. std::cout << element << " ";
  37. }
  38. std::cout << std::endl;
  39. }
  40.  
  41. return 0x0;
  42. }
Success #stdin #stdout 0s 3480KB
stdin
xxx; Spalte1;Spalte2; Spalte3; Spalte4;
A; 1; 1000; 2485; 535;
B; 5761; 10050; 244585; 534575;
C; 1457; 100750; 24855; 5354;
stdout
xxx  Spalte1 Spalte2  Spalte3  Spalte4 

A  1  1000  2485  535 

B  5761  10050  244585  534575 

C  1457  100750  24855  5354