User inputs letter, I say if it is a vowel or consonant

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string.h>

using namespace std;

char vowel[6]; //supposed to be a string that is all vowels

int main()
{

    cout << "Give me a letter, and I'll tell you if it is a vowel or a consonant: ";
    cin >> vowel;

    if ((vowel == 'a') || (vowel == 'e') || (vowel == 'i') || (vowel == 'o') || (vowel = 'u'))
        cout << "Vowel" << endl;
    else
        cout << "Consonant" << endl;

return 0;

}


I am trying to let the user input a letter, and my program will tell the user if it is a vowel or consonant. It is not running, and says error on the if line "ISO C++ forbids comparison between pointer and integer." I think my problem is the string (I am not too good with those yet). Any ideas why it is not working?
Last edited on
vowel is an array of char. When you compare it to something, you are comparing the address of the first element (i.e. a pointer); you are not comparing the contents of that address (i.e. the letter). That's not what you want.

Use a string instead of an array of char. What's meant to happen if the user types in more than one letter?

Last edited on
Topic archived. No new replies allowed.