#include <iostream>
#include <string.h>
usingnamespace 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?
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?