KK the code below is a loop part of my main program I just cut it out and made it compilable.... This is the problem... When the user enters a number greater than 2, its supposed to tell them to retry because that was not in the options menu... that works... But the thing is if the user presses a LETTER or any other characters, it goes into an infinite loop and wont exit.... in other words when it does go to retry, the user is not given a second chance to choose, its like the letter gets stuck in the memory...
Note: I have tried if (isalpha()){ goto rtry; } and that did not work at all, instead it skips retry and just exits...
#include <iostream>
#include <windows.h>
using namespace std;
int x,y,z;
int main()
{
tryagain:
cout<<"Allow me to edit registry\n";
rtry:
Sleep(1000);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
cout<<"Did You Press YES?! 1 = Yes I did , 2 = No I did not!\n";
cin>>y;
cin.ignore();
if (y == 1){
goto carryon;
}
else if (y == 2){
rtryloop:
cout<<"Would you like to allow the program to try editing the registry again? 1 = Yes , 2 = No, Just quit\n";
cin>>z;
cin.ignore();
if (z == 1){
goto tryagain;
}
else if (z == 2){
return 0;
}
else {
cout<<"You either pressed a number that is not on the menu, or a letter... Retry!\n";
goto rtryloop;
}
}
else {
cout<<"You either pressed a number that is not on the menu, or a letter... Retry!\n";
goto rtry;
}
carryon:
cout<<"Registry Editing Finished... If you pressed yes to allow the program access :)\n";
return 0;
}