Need help, been stuck on this the past couple days i dont really understand how to get my code to read from my file and count each occurence of a letter wheter they are uppr or lower case and output them to a file, just need help with the counting part, have to do it all through a function.
Here is my source code:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void getData(ifstream& inPara, ofstream& outChara, char texT[], int numLet[]);
int main()
{
ifstream inFile;
ofstream outFile;
char ch[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int numofCharacters[26] = {0};
char target;
inFile.open("Lab7.txt");//opens input file
if (!inFile)//runs error if inFile could not be opened
{
cout << "Error unable to open Input File" << endl;
cout << "Program Terminated!" << endl;
return 1;
}
outFile.open("Output.txt");//opens Output File
if (!outFile)//runs error if Output File could not be opened
{
cout << "Error unable to open Output File" << endl;
cout << "Program Terminated!" << endl;
return 1;
}
while (!inFile.eof())//runs program untile end of file
{
inFile >> target
}
inFile.close();
outFile.close();
return 0;
}
void getData(ifstream& inPara, ofstream& outChara, char texT[], int numLet[])
{
for (int i = 0; i < 26; i++) {
if (texT[i]) {
numLet[i]++;
}
}
for (int i = 0; i < 26; i++) {
cout << numLet[i] << " " << endl;
}
}