Hello, in part of the program I'm working on, I have it so the user inputs either y, Y, n, or N for an answer using cin.getline. Though in my switch function, my compiler tells me "error C2450: switch expression of type 'char ' is illegal"
here is my sample code:
cout<<"Is Botguy On Your Side? (y/n): ";
You can't use a character array to control a switch. You have to use an integral type.
However, because you only want the user to type a single character, you can use the char type here. (A char is just an integer code for a character, which is why it works in a switch.)
So instead of getline, use get or operator>> to read into a single char variable, and not a char. Then make the case statements use chars by putting single quotes instead of double quotes.
wow, that was fast! Thanks alot, I'm new at C++ so yeah. Thanks again for the help, do you want the ful code? i kinda doubt you'll need it thoguh, but if you want to...