counting the number of vowels

Hi,i am unsure how to write a function which modifies the content of the 1D character array and counts the number of the vowels. the following is the array that i have.

char text[MAX+1] = {'T', 'e', 's', 't', 'e', 'r', EOT};

the output that i am trying to produce is should look something like this

the number of vowels is 2, e, e.

i am unsure how to do this.
thanks for reading any help would be appreciated :D
Loop over each character in your character array.

Test each character to see if it is a vowel.

If it is, increment a counter for the number of vowels.
Last edited on
Thanks so much for your help!!!
i am a bit of a novice at c++ so could you explain to me how i can loop over each character.
many thanks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;


int main()
{
char vowels[]={'a','i','e','o','u'};
vector <char> str{'t','a','u','s','a','e','u'};
for(int i=0;i<5;i++){
        cout<<vowels[i]<<" = "<<count(str.begin(),str.end(),vowels[i])<<endl;


}
Topic archived. No new replies allowed.