Hi all. I am having trouble with these inside a loop I have. The loop is used to fill a struct and I want to check each input before it is accepted. It works fine if the input is what is expected but doesnt if it is incorrect input. Here is my code:
for (int i = 0; i <= 200; i++){
system("CLS");
do{
cout << "Enter employee ID: " << endl;
cin >> sheet[i].empID;
} while (isalpha(sheet[i].empID || !isdigit(sheet[i].empID)));
//it carrys on with the next cout/cin if input is correct but if its wrong
//it shoots down to where I will comment next
cout << "Enter last name: " << endl;
cin >> sheet[i].lastName;
cout << "Enter first name: " << endl;
cin >> sheet[i].firstName;
cout << "Enter department no.: " << endl;
cin >> sheet[i].dept;
cout << "Enter hours worked: " << endl;
cin >> sheet[i].hours;
if (sheet[i].hours > 37.5) {
cout << "Enter over time worked: " << endl;
cin >> sheet[i].overTime;
}
else {sheet[i].overTime = 0;}
cout << "Enter hourly rate: " << endl;
cin >> sheet[i].rate;
system("CLS");
check:
//here and then is unresponsive
cout << "1: Enter another record" << endl;
cout << "2: Return to Main Menu" << endl;
cout << "3: Exit program" << endl;
cin >> enterNext;
if (enterNext == 1) { rows++;}
else if (enterNext == 2) {break;}
else if (enterNext == 3) {exit(1);}
else {system("CLS"); goto check;}
}
}
Any ideas why or any suggestions of another way I could do this? Thanks for your time!