I Have Written A Program That Determines The Frequency Of Letters In An Input Fi

I have written a program that determines the frequency of letters in an input file.

It works perfectly but the only problem is that the output file should put the characters in the order that they appear but they are being put in alphabetical order.

Please help.

Here is the code:

#include <fstream>

#include <iostream>

using namespace std;

int main()

{

   ofstream out;

   out.open(“output.txt”);

 ifstream input(“input.txt”, ios_base::binary);

 size_t count[256];

 fill_n(count, 256, 0);

 for (char c; input.get(c); ++count[uint8_t(c)])

  ;

 for (size_t i = 0; i < 256; ++i)

 {

  if (count[i] && isgraph(i))

  {

   out << char(i) << ” ” << count[i] << ‘n’;

  }

 }

 out.close();

}

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW