elpapa wrote:Code: Select all
#include <algorithm> #include <fstream> #include <iostream> #include <sstream> #include <string> #include <vector> int main() { std::ifstream data("data.txt"); std::string line; std::vector<int> v; while (std::getline(data, line)) { v.clear(); std::istringstream parse(line); int i; while (parse >> i) v.push_back(i); std::sort(v.begin(), v.end()); for (int o : v) std::cout << o << " "; std::cout << std::endl; } std::cout << "Press Enter to exit"; std::cin.get(); return 0; }
Excellent Patrik! This works right out of the box when I add, "-std=c++11" to the compiler options ([Error] range-based-for loops not allow in C98 mode). Thanks you
