They say one should spend 90% working on the code in paper and 10% hands on; of course, I spend 90% on the computer and the other 10% scratching my head trying to figure out what's wrong.
You can write punct, chars, digits etc using a simple for loop so that you can test your algo, or put it in a function and write the stuff many times
Code:
for(int i = 0; i < 127; i++)
{
if(isalpha(i) || isdigit(i) || ispunct(i))
outFile << (char)i;
}
As for your function, I'm not positive as to what you need. The number of times each of the 26 alpha chars shows up (yikes) versus how many lower case letters there are among the total count of characters. The latter shouldn't be too difficult. I'm not saying that this is the best method but it *should* work in counting the type of each character.
Code:
void readFile(ifstream& input)
{
char dataIn;
float digits, total, lcase, ucase;
lcase = ucase = digits = total = 0;
input >> dataIn;
while(input)
{
if(islower(dataIn))
lcase++;
else if(isupper(dataIn))
ucase++;
else if(isdigit(dataIn))
digits++;
total++;
input >> dataIn;
}
cout << "The freq of lowr case is " lcase/total; // etc
}