so the user will input a file with whatever text inside and the program needs to read through each character and count how many there are of each character (uppercase and lowercase letters only). So, there could be 50 of A, 23 of b, etc...
Here's what I have so far in my main.cc:
char character;
int i = 65; //this is the iterator to go through upper and lowercase letters
int count = 0; //counts number of characters and resets when exiting the loop and after using cout
ifstream file(filename); //filename is a string the user inputs
while (i != 0) {
while (file >> character) {
int a = character;
cout << a << endl; //testing: outputs the correct number for the letter
if (i == a) { //but for some reason this part isn't working?
count++;
}
}
cout << count << endl; //this outputs 0 every time
count = 0;
i++;
if (i == 91) i = 97; //switch to lower case
if (i == 123) i = 0; //exit loop
}
I appreciate your help! thanks :)