Garmaine Staff asked 3 months ago

Whenever I input anything other than an integer, I was hoping for the catch block to execute but instead I get this error:

Unhandled exception at 0x002D0C39 in A03.exe: Stack cookie instrumentation code detected a stack-based buffer overrun. occurred

which takes me to:

if (IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE)) {

I've tried varieties of catch blocks and exceptions with the same error. Can someone tell me what I'm doing wrong? Thank you!

Here is the code:

int main() {
    while (true) {
        std::string input;
        int num = 0;

        std::cout << "What number do you want to show?";
        std::cin >> input;
            num = std::stoi(input);
            if (num >= 0 && num < 10)
                std::cout << "FILLER: This will draw the number";

            else {
                std::cout << "FILLER: This is the else";
        catch (std::runtime_error e) 
            std::cout << e.what();
            //std::cout << "That is not a valid number." << '\n';
    return 0;