number of vowels between consonants

I have to get the number of vowels that sit between consonants in a text. The thing is that if I have those words for example : "more power", the "e" in more shouldn't be taken into account.
So the ouput should be 3 using this example but I get 4.

1
2
3
4
5
6
7
8
9
10
11
12
  int main()
{  char c[25], vow[]="aeiou";
   int nr_vow=0,i;

   cin.get(c,25);
   int len =strlen(c);

   for(i=1;i<len-1;i++)
    if(!strchr(vow,c[i-1]) && strchr(vow,c[i])&& !strchr(vow,c[i+1]))
       nr_vow++;

        cout<<nr_vow;
Last edited on
You just need to add && !isspace(c[i+1]) to your conditions (and include <cctype>).
Thanks!!
Topic archived. No new replies allowed.