求大神帮忙看下这个程序错在那里
求大神帮忙看下这个程序错在那里,编译时显示没有问题,可是一运行就提示关闭进程。开始也使用二维数组存储数据,运行正常但是发现当imax 大于40000就不能很好的运行了,老提示关闭进程。后来看帖子说用malloc,但是依然提示关闭进程。求大神帮忙。#include <time.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define imax 100000
int main()
{
float stepsize=0.2;
float mesh=15;
float gridmovedis=3;
float Xmax=1057;
float Ymax=811;
float *input[imax];
int x,y,i=0,max;
FILE *out;
out=fopen("E:\\桌面\\2-50gridoutput.txt","w");
for(i=0;i<imax;i++)
input[i] = (float *)malloc(4*sizeof(float));
for(y=0;y<Ymax;y=y+gridmovedis)
for(x=0;x<Xmax;x=x+gridmovedis)
{
if((Ymax-y>=mesh)&&(Xmax-x>=mesh))
{(*(input[i]+0))=stepsize*x;
(*(input[i]+1))=stepsize*y;
(*(input[i]+2))=stepsize*(x+mesh);
(*(input[i]+3))=stepsize*(y+mesh);
i++;}
else if((Ymax-y>=mesh)&&(Xmax-x<mesh))
{(*(input[i]+0))=stepsize*x;
(*(input[i]+1))=stepsize*y;
(*(input[i]+2))=stepsize*(Xmax);
(*(input[i]+3))=stepsize*(y+mesh);
i++;}
else if((Ymax-y<mesh)&&(Xmax-x>=mesh))
{(*(input[i]+0))=stepsize*x;
(*(input[i]+1))=stepsize*y;
(*(input[i]+2))=stepsize*(x+mesh);
(*(input[i]+3))=stepsize*(Ymax);
i++;}
else if((Ymax-y<mesh)&&(Xmax-x<mesh))
{(*(input[i]+0))=stepsize*x;
(*(input[i]+1))=stepsize*y;
(*(input[i]+2))=stepsize*(Xmax);
(*(input[i]+3))=stepsize*(Ymax);
i++;}
}
max=i-1;
for(i=0;i<max;i++)
fprintf(out,"%f %f %f %f\n",(*(input[i]+0)), (*(input[i]+1)), (*(input[i]+2)), (*(input[i]+3)));
fclose(out);
return 0;
}