Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- void read_data(char *filename, int nword) {
- ifstream input(filename);
- vector<string> temp(nword); //allocate a vector of size nword
- unsigned int freq; //to store frequency counter
- do {
- //read in nword number of strings
- for (int i = 0; i < nword; i++) {
- input >> temp[i];
- }
- //read in frequency
- input >> freq;
- //TODO: do something with those vars
- cout << freq << endl;
- } while (input.good());
- input.close();
- }
- int main(int argc, char** argv) {
- if (argc < 2) {
- cerr << "missing file name" << endl;
- }
- //read 2gram, notice we passed the number of words in the second param
- read_data(argv[1], 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement