Implement the void writeToFile vector tokFreqV string outFil

Implement the void writeToFile( vector<TokenFreq> &tokFreqV, string outFileName); function. This function receives a vector of TokenFreq objects and writes each token and its frequency on a separate line in the specified output file.

Solution

void writeToFile(vector<TokenFreq> &tokFreqV, string outFileName){
ofstream outFile(outFileName.c_str());
for(int i = 0; i < tokFreqV.size(); i++){
outFile << tokFreqV[i].value << \" - \" << tokFreqV[i].freq << \"\ \";
}
outFile.close();
}

Implement the void writeToFile( vector<TokenFreq> &tokFreqV, string outFileName); function. This function receives a vector of TokenFreq objects and w

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site