fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <string>
  5. #include <vector>
  6.  
  7. int main()
  8. {
  9. std::vector<std::vector<int> > distances;
  10. //std::ifstream MyFile ("file.csv");
  11. std::istream &MyFile (std::cin);
  12. //if(MyFile.is_open())
  13. {
  14. std::string line;
  15. while(std::getline(MyFile, line))
  16. {
  17. std::istringstream row (line);
  18. distances.push_back(std::vector<int>());
  19. std::string cell;
  20. while(std::getline(row, cell, ','))
  21. {
  22. int dist;
  23. std::istringstream(cell) >> dist;
  24. distances.back().push_back(dist);
  25. }
  26. }
  27. }
  28. }
Success #stdin #stdout 0s 3036KB
stdin
0,1,2,3,4
4,3,2,1,0
9,8,7,6,5
5,6,7,8,9
stdout
Standard output is empty