char* to char fpermissive error

#include<iostream>
#include<cstring>

using namespace std;

char word[20];
char a[1]={a};
char e[1]={e};
char i[1]={i};
char o[1]={o};
char u[1]={u};

int x,y,z;

int main()
{
cout<<"Enter a Word: "<<endl;
cin>>word;
y=strlen(word);

for(z=0;z<y;z++)
{
if (word[z]==a[0])
{
x++;
}
if (word[z]==e[0])
{
x++;
}
if (word[z]==i[0])
{
x++;
}
if (word[z]==o[0])
{
x++;
}
if (word[z]==u[0])
{
x++;
}
else
{
cout<<"No Vowels Found";
}
}
return 0;
}



//pls help me on this.. thanks
Please don't double post, it's just spam - http://www.cplusplus.com/forum/general/185174/
I guess you want to count the number of vowels in a string.
Here is one to do it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <cstring>

using namespace std;

bool isVowel (char ch);

int main ()
{
  char word[20];

  cout << "Enter a Word: ";
  cin.getline(word, sizeof(word));
  
  int len = strlen (word);
  int num_vowels = 0;

  for (int z = 0; z < len; z++)
  {
    if (isVowel (word[z]))
      num_vowels++;
  }

  cout << "\n\n" << word << " constains " << num_vowels << " vowels.\n\n";

  system ("pause");
  return 0;
}

bool isVowel (char ch)
{
  char buf[] = "aeiouAEIOU";

  return strchr (buf, ch);

}

Topic archived. No new replies allowed.