vc异常0xc0000005

来源:百度知道 编辑:UC知道 时间:2024/06/25 09:31:32
我写了一段vc2005的程序,#include "stdafx.h"
#include"mystack.h"
#include"stdio.h"
#include"string.h"
int _tmain(int argc, _TCHAR* argv[])
{
char expression[100];
int index;
mystack stack1;
printf("enter the sting\n");
gets(expression);
index=0;
while(expression[index]!='\0')
{
if(expression[index]=='(')
stack1.push(expression[index]);
else if(expression[index]==')')
if(stack1.pop())
{
printf("\nnomatch");
return 1;
}
else
stack1.pop();
}
if(stack1.isEmpty())
printf("\nmatch!");
else
printf("\nnomatch");
return 0;
}

调试没问题,但运行时显异常0xc0000005 写入位置 0xccdfcb45 时发生访问冲突 ,请问这是怎么回事?
在调试的时候输入字符以后,回车就没反映了,这怎么办?

是你在写数据结构的时候访问错误
具体问题需要你把那个MyStrack的结构和实现代码发出来!否则,只能是猜测了
估计你的指针使用有误!

你的index没有自加吧?一直在检测第一个输入的字符