So what I want to do is to create a c++ function which reads in a file and converts that file's text to a vector of tokens.
Now the text file I have requires many delimiters including periods, quotation marks, etc. so I thought strtok would work better than sstream to read in tokens. However when traversing through my vector i notice there is nothing in it. The code comes up blank. What am I doing wrong?
Please help me!
My code is here:
void getTokenFreq(string inFile_name) {
ifstream inFile;
int n = 0;
char *token;
vector<string> result(1);
inFile.open(inFile_name);
if (inFile.fail()){
    cout << "Fail to open the file tmp.txt.\n";
    exit(-1);
}
while(inFile.good()) {
    getline(inFile, s);
    char *str = new char[s.length() + 1];
    strcpy(str, s.c_str());
    token = strtok(str, " ’—\",;.:?“”");
    while (token != NULL) {
        result.push_back();
        token = strtok (NULL, " ’—\",;.:?“”");
        n++;
    }
}
for(int i = 0; i < n; i++) {
    cout << result[i];
}
inFile.close();
}
 
    