编译没有问题但是运行错误 求帮助
#include "mydll.h"
#include<stdlib.h>
#include <stdio.h>
#include<math.h>
void main()
{
struct image img1,img2;
FILE *fp1,*fp2;
unsigned char *pdata;unsigned char *pdata1;unsigned char r,b,g;
int i,j,k,sum=0,a[3];
fp1=fopen("G:\\imgest\\Debug\\1.txt","w");
fp2=fopen("G:\\imgest\\Debug\\2.txt","w");
imgfiletomat("G:\\imgest\\Debug\\1.jpg", &img1);
img2.height=img1.height;img2.width=img1.width;img2.numcolors=1;
pdata1=(unsigned char*)malloc(img1.height*img1.width*sizeof(unsigned char));
for(i=0;i<img1.height;i++)
for(j=0;j<img1.width;j++)
for(k=0;k<img2.numcolors;k++){
*pdata1=rand()%255;
pdata1++;
}
img2.ptr=pdata1;
for(i=0;i<img1.height;i++)
{for(j=0;j<img1.width;j++)
for(k=0;k<img2.numcolors;k++)
{
fprintf(fp2,"%5d",*pdata1);
pdata1++;
}
fprintf(fp2,"\n");
}
createwindow("name1");
imgshow("name1",&img2);
wait(0);
mattoimgfile("G:\\imgest\\Debug\\c1.jpg",&img2);
destroywindow("name1");
destroyallwindows();
}