diff options
Diffstat (limited to '8p10.cpp')
-rw-r--r-- | 8p10.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/8p10.cpp b/8p10.cpp new file mode 100644 index 0000000..6b1ce76 --- /dev/null +++ b/8p10.cpp @@ -0,0 +1,42 @@ +#include <iostream> +#include <vector> +#include <string> +#include <sstream> +#include <fstream> + +/* + * + * 8.10 + * + * + */ + +int main (int argc, char **argv) { + + if(argc < 2 || argc > 2) { + return -1; + } + + std::ifstream file(argv[1]); + if(file.fail()) { + std::cerr << argv[0] << ": cannot open file '" << argv[1] << "'" << std::endl; + return -1; + } + + std::vector<std::string> all_lines; + std::string cur_line; + while(getline(file, cur_line)) { + all_lines.push_back(cur_line); + } + + for(auto &ref_all_lines : all_lines) { + std::istringstream is(ref_all_lines); + std::string is_tmp; + while(is >> is_tmp) { + std::cout << is_tmp << "\n"; + } + } + + std::cout << std::ends; + return 0; +} |