I am a newbie... trying to make this simple program accept a character input A-F. If not A-F give a message and get another character.
This is not working, does anyone see my mistake?
Any help would be greatly appreciated.
Regards,
Trope
This is not working, does anyone see my mistake?
Code:
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
// Init user input
char licenseLetter;
bool inputValid = false;
// Get user input
do
{
cout << "Enter selection letter: ";
cin >> licenseLetter;
// Validate
if(licenseLetter<"A" || licenseLetter>"F"){
cout << "Invalid Selection. A-F only, please." << endl;
} else {
// ok, move on and do other stuff
inputValid = true;
}
} while (inputValid == false);
cout << "You entered: " << licenseLetter << endl;
return 0;
}
Any help would be greatly appreciated.
Regards,
Trope