Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi I\'m having a little trouble trying to start this function thatwill read in c

ID: 3609915 • Letter: H

Question

Hi I'm having a little trouble trying to start this function thatwill read in character frequencies from a file.
My professor expects us to know how to do it even though he barelytouched on it.
What I basically do is create an array of 256 integers to store thefrequency counts, one for each possible character that can bestored in one byte. Initially, all of the counts are 0. Now readeach character of the file, adding 1 to its count. The function isnot suppose to skip over any blanks, its basically suppose to reada "/n" and a blank " " and print how many times it occurs with thefrequencies from the file.

Here is what I have so far an I on the right track?


void readFile(char* fname)
{
ifstream in(fname);
if(in.fail())
{
    cout << "The file does not exsist ";
}

cout << "The character frequencies are: ";
while(!in.eof())
{
// print out frequencies here
}
   in.close();
cout << " ";

Explanation / Answer

/* Took number of character according to ASCII as 128 Therefore size of array tos tore frequencies is 128 */ #include #include #include using namespace std; int main() {         ifstream inFile;     inFile.open("input.txt"); if (inFile.fail()) {       cerr
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote