我制作了一个包含3个问题的问答程序(控制台应用程序),它在CodeBlocks 17.12(调试版本)中可以正常工作,但是在发行版本(.exe文件)中,它可以在正确回答时崩溃而没有任何错误第三个问题。输入正确答案后,程序不会崩溃。
我尝试使用WinDbg Preview进行调试,但大多数情况下它无法正常工作,并且在正确回答第三个问题并正常运行时,程序也不会崩溃。 我也尝试删除SetConsoleAttribute颜色,但这也不起作用。
#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;
}
}