I am trying to create an Array which would let the user input up to 80 characters and then when the program halts, for the program to return the amount of times each vowel shows up in the Array. I successfully got it to work last week, but the coding got lost and I had to do it from scratch.
Edit: The problem I am having is that based on the current structure, all the counters still return 0 at the end.
I remember that I used the following coding, but I am having issues with the counters actually working. I think I had the segment for the counters in a loop of its own, but I can't remember it.
I also want the program to halt if the user presses ENTER, but I have no idea how that works.
Any help would be appreciated.
#include <iostream>
#include <iostream>
using namespace std;
int main()
{
int x = 0;
char thisArray[80];
int aCounter = 0, eCounter = 0, iCounter = 0, oCounter = 0, uCounter = 0;
cout << "Please enter up to 80 characters and you will be told" << endl;
cout << "how many times each vowel is in the array." << endl;
do{
cout << "Please enter a character" << endl;
cin >> thisArray;
x++;
} while (x < 80);
for (x = 0; x <= thisArray[x]; x++) {
if (thisArray[x] == 'a')
aCounter = aCounter + 1;
else if (thisArray[x] == 'e')
eCounter = eCounter + 1;
else if (thisArray[x] == 'i')
iCounter = iCounter + 1;
else if (thisArray[x] == 'o')
oCounter = oCounter + 1;
else if (thisArray[x] == 'u')
uCounter = uCounter + 1;
}
cout << "Vowel count:" << endl;
cout << "Total number of A's." << aCounter << endl;
cout << "Total number of E's." << eCounter << endl;
cout << "Total number of I's." << iCounter << endl;
cout << "Total number of O's." << oCounter << endl;
cout << "Total number of U's." << uCounter << endl;
system("pause");
}