hi,
I'm trying to create a program that will read a file and then check the file for each letter of the alphabet and then output the letter and the number of times it appears in the file, into a new file... this is what i have so far but it's not working.. if anyone could help that would be nice!
thanks
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
cout << "\n To find the number of occurrences of each letter in the alphabet in a specific file,"
<< "enter the file name:";
string inFile;
cin >> inFile;
cout << "\nEnter the name of the output file:";
string outFile;
cin >> outFile;
ifstream fin(inFile.data());
assert (fin.is_open());
ofstream fout(outFile.data());
assert (fout.is_open());
vector<int> numoccurrences(26);
int i;
char letter;
for(;

{
fin >> letter;
char lowercase = tolower(letter);
if ('a'<= lowercase <='z')
numoccurrences[ lowercase - 'a']++;
}
char ch = 0;
for (int i = 1; i < numoccurrences.size(); i++)
{
fout << ch << numoccurrences[i];
ch++;
}
}