0xC0000005:访问冲突读取位置0x00000000 c++
0xC0000005: Access violation reading location 0x00000000 c++
这是我的大学作业。我必须从文本文件中的一行中读取波兰符号。在文本文件中的表达式是:"/2 3 ",我必须把它变成一个反向波兰符号。我一直得到这个错误:0xC0000005:访问冲突读取位置0x00000000。
int top = -1;
char prefix[50];
void Push(char value)
{
top++;
prefix[top] = value;
}
void Pop()
{
if (top < 0)
cout << "The stack is empty." << endl;
else
{
top--;
}
}
char Top()
{
return prefix[top];
}
void Display()
{
for (int i = 0; i <= top; i++)
cout << prefix[i] << " ";
}
bool isOperator(char c)
{
if (c == '+' || c == '-' || c == '*' || c == '/')
return true;
else
return false;
}
char c;
char postfix[50];
int top2 = -1;
void Push2()
{
top2++;
postfix[top2] = Top() + Top() + c;
}
void Display2()
{
{
for (int i = 0; i <= top2; i++)
cout << postfix[i] << " ";
}
};
void PrefixToPostfix()
{
for (int *i = 0; *i <= top2; i++)
{
c = prefix[*i];
if (isOperator)
{
Push2();
}
else
{
top2++;
postfix[top2] = c;
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char value;
char c;
ifstream file("Prefix.txt");
while (file >> value)
{
Push(value);
}
file.close();
PrefixToPostfix();
Display();
Display2();
cout << endl;
system("PAUSE");
return 0;
}
我认为错误可能在我的代码的这一部分:
void PrefixToPostfix()
{
for (int *i = 0; *i <= top2; i++)
{
c = prefix[*i];
如果有人能帮助我,我会非常感激,因为我必须在5个小时内交作业。:) 此处不需要指针:
for (int i = 0; i <= top2; i++) {
c = prefix[i]; }
相关文章:
- 0xC0000005:访问冲突读取位置 0x00000000. 重载 == 运算符的问题
- OPENCV.3.0错误:0xc0000005:访问违规读取位置0x00000000
- 在为矩阵分配值时访问冲突写入位置0x00000000
- 访问违规写作位置0x00000000在阅读/写入向量时
- OpenGL:glDrawArrays()引发异常(nvoglv32.dll)读取位置0x00000000时发生访问冲突
- NVIDIA 在 <work.exe>0xC0000005 中0x002a2da2未处理的异常:访问违规读取位置0x00000000
- 访问冲突写入位置0x00000000.C++/SFML游戏
- 0xC0000005:访问违规读取位置0x00000000
- IXAudio2 - 0xC0000005:访问冲突写入位置0x00000000
- 0xC0000005:访问冲突读取位置0x00000000哈希函数
- 引擎.exe 0x00000000时未处理的异常: 0xC0000005:访问冲突
- 填充数组(写入位置0x00000000的访问冲突)
- "First-chance exception at 0x00000000" 我做错了什么?
- DirectX11 网格加载 - 由于纹理而出错(使用 SDKmesh.h)?访问违规读取位置0x00000000
- 0x00000000时分段错误错误
- C++:0xC0000005:访问违规写入位置0x00000000
- 未处理的异常 - 访问冲突读取位置0x00000000
- 访问冲突写入位置0x00000000.内存集函数问题
- 0xC0000005:访问违规读取位置0x00000000
- glibc 检测到 *** ./burcu.exe: free(): 无效的下一个大小 (快速): 0x00000000