求助数组问题
我 在main 函数前用了一个宏定义#define MAXROW 92800
后面定义了一个数组,a[MAXROW],结果运行时出错,请问是怎么回事?是因为数组越界了吗?谢谢!附我的整个程序
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXROW1 927552
#define MAXROW2 625589
#define MAXCOLUMN 200
main()
{
int j=0,k=0;
short plateid1[MAXROW1],plateid2[MAXROW2];
short field1[MAXROW1],field2[MAXROW2];
int mjd1[MAXROW1],mjd2[MAXROW2];
double z2[MAXROW2],ra[MAXROW2],dec[MAXROW2],g[MAXROW2];
float z1[MAXROW1],mediamass[MAXROW1],p97p5[MAXROW1],mode[MAXROW1],avg[MAXROW1];
char line[MAXCOLUMN];
FILE *infp1;
FILE *infp2;
FILE *outfp;
outfp=fopen("/end","w");
if ((infp2=fopen("/data2.txt","r"))==NULL)
{
printf("cannot open infile\n");
return 1;
}
while ((fgets(line,MAXCOLUMN,infp2))!= NULL)
{
sscanf(line,"%hd %d %hd %lf %lf %lf %lf",&plateid2[j],&mjd2[j],&field2[j],&ra[j],&dec[j],&z2[j],&g[j]);
// printf("%4d %6d %4d %12f %10.8f %20.16f %20.15f\n",plateid2[j],mjd2[j],field2[j],ra[j],dec[j],z2[j],g[j]);
j++;
}
if ((infp1=fopen("/data1.txt","r"))==NULL)
{
printf("cannot open infile\n");
return 1;
}
while ((fgets(line,MAXCOLUMN,infp1))!= NULL)
{
sscanf(line,"%hd %d %hd %f %f %f %f %f",&plateid1[k],&mjd1[k],&field1[k],&z1[k],&mediamass[k],&p97p5[k],&mode[k],&avg[k]);
// printf("%4d %6d %4d %e %e %e %e %e\n",plateid1[k],mjd1[k],field1[k],z1[k],mediamass[k],p97p5[k],mode[k],avg[k]);
k++;
}
for (j=0;j<MAXROW2;j++)
{
for (k=0;k<MAXROW1;k++)
{
if (plateid2[j]==plateid1[k]&& mjd2[j]==mjd1[k]&& field2[j]==field1[k])
fprintf (outfp,"%4d %6d %4d %4d %6d %4d %e %e %e %e %e %12f %10.8f %20.16f %20.15f\n",plateid1[k],mjd1[k],field1[k],plateid2[j],mjd2[j],field2[j],z1[k],mediamass[k],p97p5[k],mode[k],avg[k],ra[j],dec[j],z2[j],g[j]);
}
}
fclose(infp2);
fclose(infp1);
fclose(outfp);
return 0;
}
[ 本帖最后由 myphenix 于 2011-2-24 10:10 编辑 ]