-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.cpp
More file actions
57 lines (44 loc) · 843 Bytes
/
split.cpp
File metadata and controls
57 lines (44 loc) · 843 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <fstream>
#include <sstream>
#include <iostream>
#include <iterator>
#include <vector>
#include <cctype>
using namespace std;
vector<string> split(string& s, char delimiter)
{
vector<string> tokens;
string token;
istringstream tokenStream(s);
while (getline(tokenStream, token, delimiter))
{
tokens.emplace_back(token);
}
return tokens;
}
void print_vector(vector<string>& v)
{
for (auto& val : v)
{
cout << val << " ";
for (auto& c : val)
{
c = toupper(c);
cout << c;
}
cout << endl;
}
cout << endl;
}
int main(int argc, char* argv[])
{
string text;
getline(cin, text);
// cout << text << endl;
istringstream iss(text);
// vector<string> v((istream_iterator<string>(iss)), istream_iterator<string>());
auto vec = split(text, ' ');
// print_vector(v);
print_vector(vec);
return 0;
}