-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathExer10_29.cpp
More file actions
36 lines (36 loc) · 756 Bytes
/
Exer10_29.cpp
File metadata and controls
36 lines (36 loc) · 756 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <iterator>
using std::cout;
using std::cin;
using std::cerr;
using std::endl;
using std::ifstream;
using std::ofstream;
using std::string;
using std::vector;
using std::istream_iterator;
using std::ostream_iterator;
int main(int argc, char *argv[])
{
if(argc != 2)
{ cerr << "Wrong input!" << endl;
return -1;
}
ifstream is(argv[1]);
istream_iterator<string> is_iter(is), eof;
ostream_iterator<string> os_iter(cout, " ");
vector<string> vec;
string str;
while(is_iter != eof)
{
str = *is_iter++;
vec.push_back(str);
}
for(const auto &s : vec)
os_iter = s;
cout << endl;
return 0;
}