程序编译正确,总是执行出错是什么原因
编译都是正确的,但是执行时就回弹出对话框说程序出错,要关闭程序是什么原因,请高人指教!#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void main()
{
float a[490][1200],b[1200000];
int i=0;
int j=0;
FILE *fp,*fp1,*fp2;
//打开原数据文件 写成剔除乱码后文件 数组文件
if ( (fp=fopen( "f:\\chuli\\0.2 0.2.txt ", "r"))==NULL)
{
printf( "file not open!\n ");
exit(0);
}
if ( (fp1=fopen("f:\\chuli\\0.2 0.2 1.txt", "w"))==NULL)
{
printf("file not open!\n");
exit(0);
}
if ((fp2=fopen("f:\\chuli\\0.2 0.2 2.txt", "w"))==NULL)
{
printf("file not open!\n");
exit(0);
}
//仅保留一个乱码
for (i=0;;i++)
{
if ((fscanf(fp,"%f",&b[i])!=EOF)&&(fscanf(fp,"%f",&b[i])!=-999.999)&&(fscanf(fp,"%f",&b[i])!=999.999)) fprintf(fp1,"%f/n",b[i]);
else if ((fscanf(fp,"%f",&b[i])==-999.999)||(fscanf(fp,"%f",&b[i])==999.999))
{
fprintf(fp1,"%f/n",&b[i]);
do
{
i++;
}
while ((fscanf(fp,"%f",&b[i])==-999.999)||(fscanf(fp,"%f",&b[i])==999.999));
i--;
}
else if (fscanf(fp,"%f",&b[i])==EOF) break;
}
//写成二维数组文件
for (i=0; i<490; i++)
{
for (j=0; j<1200; j++)
{
if((fscanf(fp1,"%f",&a[i][j])!=EOF)&&(fscanf(fp1,"%f",&a[i][j])!=-999.999)&&(fscanf(fp1,"%f",&a[i][j])!=999.999)) fprintf(fp2,"%f ",a[i][j]);
else if ((fscanf(fp1,"%f",&a[i][j])==-999.999)||(fscanf(fp1,"%f",&a[i][j])==999.999)) //每一行的最后一列数字均为乱码
{
fprintf(fp2,"/n");
break;
}
}
// printf( "\n");
}
fcloseall();
}