summaryrefslogtreecommitdiff
path: root/8p10.cpp
blob: 6b1ce76c8166ba80d003eb2859e3f4296f6588c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
}