msvcr110d.dll中出现未处理的异常
Unhandled exception in msvcr110d.dll
一切似乎都很好,但当我输入I
时,它显示
Unhandled exception at 0x64A1EB90 (msvcr110d.dll) in ConsoleGame1.exe: 0xC0000005: Access violation writing location 0xCCCCCCCC.
First-chance exception at 0x64A1EB90 (msvcr110d.dll) in ConsoleGame1.exe: 0xC0000005: Access violation writing location 0xCCCCCCCC.
Unhandled exception at 0x64A1EB90 (msvcr110d.dll) in ConsoleGame1.exe: 0xC0000005: Access violation writing location 0xCCCCCCCC.
The program '[5088] ConsoleGame1.exe' has exited with code 0 (0x0).
代码:
void Inventory();
struct Item
{
string itemName;
string itemDescription;
int itemNumber;
bool haveItem;
void DisplayItem();
};
int main()
{
char inv;
hint:
cout << "HINT: To open your inventory press 'I'.n";
cin >> inv;
if (inv=='I') Inventory();
else goto hint;
system("pause");
return 0;
}
void Inventory()
{
Item Letter =
{
Letter.itemName = "Letter",
Letter.itemDescription = "...",
Letter.itemNumber = 1,
Letter.haveItem = true
};
Item Wood =
{
Wood.itemName = "Wood",
Wood.itemDescription = "Birch wood.",
Wood.itemNumber = 2,
Wood.haveItem = false
};
Letter.DisplayItem();
Wood.DisplayItem();
}
为了解决手头的问题,您将分配给尚未构建的对象:
Item Letter =
{
Letter.itemName = "Letter",
Letter.itemDescription = "...",
Letter.itemNumber = 1,
Letter.haveItem = true
};
在指定初始化Letter
的参数时,您将分配给Letter
的成员。那不行。你想要的是:
Item Letter =
{
"Letter",
"...",
1,
true
};
然而,正如我在评论中所说,代码总体上表明,你最好从基础开始,写一本好书来指导你。例如,您肯定不想使用goto
而不是循环。并且Item
类可以使用构造函数。
相关文章:
- 如何修复链表类实现的未处理异常0xDDDDDDDD
- VisualC++ 2010 有没有办法找出有关未处理异常错误的更多详细信息
- C++ 程序中双链表的未处理异常
- 运算符重载时未处理<<异常
- 实验室中0x6BE20E11 (ucrtbased.dll) 的未处理异常.exe: 0xC0000005:访问冲突读取
- ImageMagick 的未处理异常
- 类数组大小为的未处理异常
- 尝试将构造函数设置为 0 - c++ 的未处理异常
- Dijkstra 中0x001e1078 s_Algorithm.exe的未处理异常:0xC0000005:访问冲突读取位置0xbaadf00d
- 运算符重载未处理异常
- 尝试使用 fread 读取文本文件时发生 'System.AccessViolationException' 类型的未处理异常
- c++中的Guard,在main中未处理异常时不调用析构函数
- 某些内存位置的未处理异常
- 错误 linkedlist .exe 中0x00D0345E处的未处理异常: 0xC0000005:访问违规写入位置0x
- 仅在发布模式下使用 glGenBuffer 的未处理异常 - QT
- 如何分析VS2010在调试模式下捕获的未处理异常
- glDrawArrays上的openGL未处理异常(GL_TRIANGLES,0,model.indicesCount)
- 使用Boost Spirit解析语法的未处理异常
- 解析"%Z" C++ 中将错误作为访问 voilation 的未处理异常给出?
- 为什么在win32计时器回调中引发的未处理异常未被调试器视为未处理异常