There is a loop i want to run and check for valid input, if not valid jump out the itteration and start at the beginning of the loop where i ask for input.
close = false;
int direction
while (!close){
if (!(cin >> direction)){
cout << "not valid: " << endl;
continue;
}
close = true;
}
However when I run it I can only enter the direction one time and not reenter it when continue is reached. How can I end a itteration and let the user retry.
When adding the variable to the while loop and remove from above the while loop (it's local to the while loop and destroyed outside than right?) like
while (!close){
int direction;
////
}
it also dosn't work. I know the whole part of code could be better but I just started with c++ and am trying to understand why it dosn't work like i expect.