程序错误:未处理的异常: 0xC0000005: 写入位置 0x00000000 时发生访问冲突

来源:百度知道 编辑:UC知道 时间:2024/05/16 11:42:04
for(int i=1;i<=10;i++)
{
FILE *fp,*fp1;
char sFileName[100];
char num[4];
itoa(i,num,10);
strcpy(sFileName,".\\pic\\photo");
strcat(sFileName,num);
strcat(sFileName,".bmp");
if((fp=fopen(sFileName,"r"))=NULL)
{
MessageBox(_T("The File is not exit!"));
break;
}
else
{
int width,height;
fp=fopen(sFileName,"rb");
fseek(fp,18,SEEK_CUR);
fread(&width,1,4,fp);
fread(&height,1,4,fp);
fseek(fp,32,SEEK_CUR);
int **ppInt=D2Array(height,width);
fread(ppInt,3,width*height,fp);
int *writeData = (int *)malloc(116*144*(sizeof(int)));
int gx,gy;
long int i=0;
float deltax,deltay;
float dx,dx1,dy,dy1;
float xx,yy,zz;
float gray;
int x1,x2,y1,y2;
deltax=(float)width/116;

0xC0000005: 一般是只读内存区域 有写操作的情况出现的,
比如 某个指针 地址为 NULL 的时候。

我没有试验,猜测是因为writeData[i] 中i的值已经超过了缓冲区的定义空间。你加入调试信息看看吧。

另外调试下 int *writeData = (int *)malloc(116*144*(sizeof(int))); 是否分配成功了····