C++ 错误R6010。为什么叫它?
我正在创建一个基本的2D游戏。我的代码在VisualStudio2010中运行良好。然而,当我创建一个.exe并运行它时,我收到一条消息,说明“调试错误,R6010,中止已被调用” 通过从头开始,添加代码位直到找到错误,我将问题缩小到下面的代码。我已经包含了整个函数,但如果需要,可以提供更多的代码 对其他人问题的回答表明,问题与未被捕获的错误有关(我曾尝试过try/catch语句,但没有任何效果)。但是,在调试模式下,如果没有它们,我看不到代码在哪里运行 如果有人有任何建议,我将不胜感激C++ 错误R6010。为什么叫它?,c++,abort,C++,Abort,我正在创建一个基本的2D游戏。我的代码在VisualStudio2010中运行良好。然而,当我创建一个.exe并运行它时,我收到一条消息,说明“调试错误,R6010,中止已被调用” 通过从头开始,添加代码位直到找到错误,我将问题缩小到下面的代码。我已经包含了整个函数,但如果需要,可以提供更多的代码 对其他人问题的回答表明,问题与未被捕获的错误有关(我曾尝试过try/catch语句,但没有任何效果)。但是,在调试模式下,如果没有它们,我看不到代码在哪里运行 如果有人有任何建议,我将不胜感激 v
void initGUI()
{
//Button Types correspond to which section of the screen the button will be displayed in.
//type 1 = Top Bar,
//type 2 = Main Body,
//type 3 = Overlay window (gui1 only)
bool endFile = false;
string totalGUIString;
string text;
vector<string> stringVector;
//Open the file
cout << "Opening file buttons.txt" << endl;
fstream textFile;
textFile.open("buttons.txt");
//Read the first line and determine the amount of GUI's that need to be created
textFile >> totalGUIString;
int totalGUIs = convertStringToInt(totalGUIString);
cout << "Total number of GUI's to load = " << totalGUIs << endl;
//Create the correct amount of GUI's
for(int j = 0; j < totalGUIs; j++)
{
guiMatrix.push_back(gui(j));
}
textFile >> text;
while(endFile == false) //Search through the main body of the file
{
//textFile >> text;
if(text == "END")
{
endFile = true;
cout << "Reached the end of the file" << endl;
}
else
{
stringVector.push_back(text);
//cout << "PushBack:" << text << endl;
if(text == "E")
{
//Use vector to populate the button constructor
int button0 = convertStringToInt(stringVector[0]);
int button1 = convertStringToInt(stringVector[1]);
string button2 = stringVector[2];
int button3 = convertStringToInt(stringVector[3]);
//cout << "TESTING:: " << button0 << " " << button1 << " " << button2 << " " << button3 << endl;
guiMatrix[button0].addButton(button1, button2, button3);
stringVector.clear();
}
textFile >> text;
}
}
textFile.close();
//For every guiMatrix print the button list to cout.
for(int a = 0; a < totalGUIs; a++)
{
guiMatrix[a].printButtonMatrix();
}
}
当
.exe找不到.png
文件时抛出错误。
没有规定如果找不到这些文件应该怎么做
通过将相关的
.png
文件移动到与可执行文件相同的文件夹中来解决 应该有一个为发布而构建的选项,尝试一下……只是在发布模式下尝试过。错误仍然存在。确定文件已打开/找到吗?总是很简单的事情。由于某些原因,.exe找不到包含其余文件的.txt文件。我已将它复制到与.exe相同的文件夹中,并且它可以正常工作。我必须确保这一点在以后的计划中得到体现。谢谢
5
0 2 Explore 0 E
0 2 Technologies 0 E
0 2 Buildings 0 E
0 2 Workers 0 E
0 1 Scoop_Water 10 E
0 1 Collect_Water 10 E
0 1 Forage 10 E
0 1 Gather_Twigs 10 E
0 1 Fell_Trees 10 E
1 2 Enter 0 E
1 1 Build_Road 1 E
2 2 Explore 0 E
2 2 Main 0 E
2 2 Buildings 0 E
2 2 Workers 0 E
2 1 Backpack 0 E
2 1 Hand_Cart 0 E
3 2 Explore 0 E
3 2 Main 0 E
3 2 Technologies 0 E
3 2 Workers
3 1 Build_Hut 0 E
4 2 Explore 0 E
4 2 Main 0 E
4 2 Technologies 0 E
4 2 Buildings 0 E
END