Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7190

Question and Answer program crashes on release build, works fine on debug build

$
0
0

I have made a question and answer program (Console application) with 3 questions, it works just fine in CodeBlocks 17.12 (debug build), but on the release build ( the .exe file ) it crashes without any error when correctly answering the 3rd question. The program doesn't crash when putting in the wrong answer.

I tried to debug with WinDbg Preview but most of the time it didn't work and when it did the program did NOT crash when correctly answering the 3rd question and worked as normal. I also tried to remove the SetConsoleAttribute colors, but that didn't work either.

#include <iostream>
#include <cstdlib>
#include <stdlib.h>
#include <windows.h>

using namespace std;

int main()
{
SetConsoleTitle("Bloodrush: The Game");
cout << "Question 3"<< endl;
cout << "text"<< endl;
cout << "A)"<< endl;
cout << "B)"<< endl;
cout << "C)"<< endl;
cout << "D)"<< endl;
cout << "E)"<< endl;
string ANSWER3;
cin >> ANSWER3;
if ((ANSWER3 == "E") || (ANSWER3 == "e") || (ANSWER3 == "e)") || (ANSWER3 == "e)"))
 {
   if (system("CLS"))
        system("clear");
    cout << "text"<< endl;
    cout << "text"<< endl;
    cout << "text \n"<< endl;
    cout << "text"<< endl;
    return 0;
  }
    else
    {
            SetConsoleTitle("Wrong Answer");
            if (system("CLS")) system("clear");
            cout << "text \n"<< endl;
            cout << "Press ENTER to return to the MAIN MENU..."<< endl;
            cin.ignore();
            cin.get();
            cout << "no menu"<< endl;
    }
}


Viewing all articles
Browse latest Browse all 7190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>