这个程序为什么在读文件时候读不全数据?
txt(数据):4700.7100 -16.801 73.331 115.494 37.617 11414.634 1.009 8.802 9.738 9.444 15.011 10.455 20.906 11.063 25.445 5.398 -10.843 4.156 -13.112 3.634 -21.069 1.326 -25.070
4700.7397 -15.651 73.156 115.494 37.619 11415.498 1.009 8.802 9.740 9.444 15.003 10.455 20.897 11.076 25.430 5.415 -10.829 4.169 -13.517 3.645 -21.067 1.340 -25.064
4700.7700 -15.872 73.076 115.493 37.618 11416.296 1.010 8.802 9.745 9.444 14.998 10.455 20.887 11.088 25.416 5.433 -10.821 4.183 -13.924 3.657 -21.065 1.356 -25.058
4700.7998 -17.139 73.033 115.493 37.618 11416.997 1.011 8.802 9.745 9.444 14.993 10.455 20.879 11.099 25.412 5.450 -10.814 4.196 -14.308 3.668 -21.064 1.375 -25.051
4700.8296 -16.420 73.025 115.493 37.619 11417.612 1.012 8.802 9.750 9.444 14.989 10.455 20.866 11.110 25.391 5.466 -10.818 4.209 -14.683 3.679 -21.064 1.397 -25.039
4700.8599 -16.197 72.993 115.493 37.620 11418.146 1.013 8.802 9.748 9.444 14.987 10.455 20.854 11.121 25.394 5.481 -10.815 4.223 -15.048 3.691 -21.060 1.422 -25.032
4700.8896 -16.821 72.956 115.493 37.619 11418.576 1.014 8.802 9.753 9.444 14.994 10.455 20.859 11.132 25.387 5.496 -10.821 4.236 -15.385 3.703 -21.057 1.448 -25.017
4700.9199 -16.492 72.975 115.493 37.620 11418.917 1.015 8.802 9.759 9.444 14.994 10.455 20.850 11.142 25.392 5.511 -10.818 4.249 -15.700 3.716 -21.055 1.478 -25.017
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 1840
#define ROW 8
#define COLUMN 23
void main()
{
FILE *fp;
int i=0;
int left=1;
int right = 1;
double sum = 0.0;
char *filename = "data.txt";
char ch;
char data[MAXSIZE]={0};
int num[MAXSIZE]={0};
double result[ROW*COLUMN];
int t=0;
fp = fopen(filename, "r");
if (fp == NULL)
{
printf("NULL\n");
exit(0);
}
else
printf("suc\n");
ch = fgetc(fp);
while (ch != EOF)
{
data[i] = ch;
ch = fgetc(fp);
i++;
}
for(i = 0; i< MAXSIZE; i++)
{
num[i] = (int(data[i]) - 48);
}
printf("______________________");
printf("%s\n",data);
printf("______________________");
fclose(fp);
for (i = 0; i < MAXSIZE; i++)
{
double leftweiquan = 1;
double rightweiquan = 0.1;
double flag = 1.0;
left = 1;
right = 1;
sum = 0.0;
if (num[i] == -2)
{
while(num[i - left]>=0 && num[i - left]<=9 && (i-left) >= 0)
{
sum+= ((num[i - left])) * leftweiquan*1.0;
leftweiquan *= 10;
left++;
}
while(num[i + right] >= 0 && num[i+right] <= 9)
{
sum+=((num[i + right]))*rightweiquan*1.0;
rightweiquan /= 10;
right++;
}
result[t] = sum;
t++;
}
}
}