#include #include #include #include #include // std::size_t /* finddelim.cpp */ using std::cout; using std::cin; using std::cerr; using std::endl; using std::string; using std::vector; using std::ifstream; string readFileIntoString(const string path) { ifstream input_file(path); if (!input_file.is_open()) { cerr << "Could not open the file - '" << path << "'" << endl; exit(EXIT_FAILURE); } string f= string((std::istreambuf_iterator(input_file)), std::istreambuf_iterator()); input_file.close(); return f; } vector findDigits(string data) { std::size_t pos; string delim="-"; vector numbers; while ((pos = data.find(delim)) != string::npos) { numbers.push_back(data.substr(0, pos)); data.erase(0, pos + delim.length()); }// get last numbera on tail if any if(data.size()>0) numbers.push_back(data); return numbers; } vector removeEmpties(vector v) { auto isEmptyOrBlank = [](const std::string &s) { return s.find_first_not_of(" \t") == std::string::npos; }; v.erase(std::remove_if(v.begin(), v.end(), isEmptyOrBlank), v.end()); return v; } int main (){ /* test file --242----2-343---3-33---943-3--3-5-223--848344- */ string filename="finddigits"; string file_contents; file_contents = readFileIntoString(filename); cout << file_contents << endl; vectornum= removeEmpties(findDigits(readFileIntoString(filename))); for(const auto &n:num) cout<< n <<" "; cout<