void command()
{
int CourseDistance, StartTime, FinishTime;
char cmdChar = ' ';
do
{
cout << "Command? : ";
cin.get(cmdChar);
switch (cmdChar)
{
case 'd':
case 'D':
cout << "Enter New Course Distance (NM): ";
cin >> CourseDistance;
break;
case 's':
case 'S':
cout << "Enter New Race Start Time (08:00-17:00): ";
cin >> StartTime;
break;
case 'f':
case 'F':
cout << "Enter Finish Time (Max Start + 24h, 0-23:59): ";
cin >> FinishTime;
break;
default:
cout << "Unknown!\n";
}
} while (cmdChar != 'q');
}
my question is why does my output go like
Command? : d
Enter New Course Distance (NM): 10
Command? : Unknown!
Command? :
after I input a 10, a new command prompt comes up but automatically puts an "Unknown!" there and then asks for an input again. why does it do that? How can I not let the Unknown happen?
thank you!