-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcsv-cc.cc
More file actions
34 lines (29 loc) · 789 Bytes
/
csv-cc.cc
File metadata and controls
34 lines (29 loc) · 789 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
#include <iostream> // cout, endl
#include <fstream> // fstream
#include <vector>
#include <string>
#include <algorithm> // copy
#include <iterator> // ostream_operator
#include <boost/tokenizer.hpp>
int main (int argc, char* argv[]) {
std::string data;
if (argc == 1) {
data = "/dev/stdin";
}
else {
data = argv[1];
}
std::ifstream in (data.c_str ());
if (!in.is_open ()) return 1;
typedef boost::tokenizer<boost::escaped_list_separator<char>> Tokenizer;
std::vector<std::string> vec;
std::string line;
int sum = 0;
while (getline (in, line)) {
Tokenizer tok (line);
for (auto token : tok) {
sum += 1;
}
}
std::cout << sum << std::endl;
}