In the switch function if you enter a letter or character the default case bugs out and is stuck in a infinite loop. Here is a mini version I created.
#include <iostream>
#include <string>
#include <cmath>
#include <unistd.h>
#include <chrono>
#include <thread>
#include <fstream>
#include <random>
#include <time.h>
using namespace std;
void sleepcp(int milliseconds)
{
clock_t time_end;
time_end = clock() + milliseconds * CLOCKS_PER_SEC/1000;
while (clock() < time_end)
{
}
}
int main() {
START:
int x;
cout << "Enter a number: ";
cin >> x;
switch (x) {
case 1:
cout << "Hi"<< endl;
sleepcp(250);
system("clear");
goto START;
default:
cout << "Incorrect"<< endl;
sleepcp(250);
system("clear");
goto START;
}
}
Now if you run this code and type a character such as m it will constantly show Incorrect and will not receive any user input.