Creating a program which counts the number of A's B's C's D's E's and F's in one of Plato's works and then create another file (called statistics.txt) which lists the different values of each letter. I believe I've created the code necessary to calculate this, however I'm not exactly sure how to insert the values I've found into the output file. Should be pretty easy to answer. Thanks!
Here's the code for what its worth...
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, const char * argv[])
{
int numA = 0;
int numB = 0;
int numC = 0;
int numD = 0;
int numE = 0;
int numF = 0;
char c = ' ';
ifstream myFile;
myFile.open("plato.txt");
if(!myFile)
{
cout << "Error: File could not be found:" << endl;
}
while (myFile.good())
{
c = myFile.get();
if ((c == 'a' || c == 'A'))
{
++numA;
}
if ((c == 'b' || c == 'B'))
{
++numB;
}
if ((c == 'c' || c == 'C'))
{
++numC;
}
if ((c == 'd' || c == 'D'))
{
++numD;
}
if ((c == 'e' || c == 'E'))
{
++numE;
}
if ((c == 'f' || c == 'F'))
{
++numF;
}
newFile << "Total Number of A's is" << numA << \n << << "Total Number of B's is" << numB << \n<< "Total Number of C's is" << numC << \n<< "Total Number of D's is" << numD << \n<< "Total Number of E's is" << numE << \n << "Total Number of F's is" << numF << \n;
newFile.close();
}