文件读入问题
我想从temp.dat读入数据 并显示出来,代码如下#include<stdio.h>
#include<stdlib.h>
#define N 5845
int main()
{
FILE *fp;
char id[10];
float x,y,z;
int i;
if((fp=fopen("D:\\temp.dat","r"))==NULL)
{puts("ERROR!");exit(0);}
for(i=0;i<N;i++)
{
fscanf(fp,"%s,,%f,%f,%f",id,&x,&y,&z);
printf("%-10s%-10f%-10f%-10f\n",id,x,y,z);
}
fclose(fp);
system("pause");
return 0;
}
部分temp.dat如下
18x,,479624.053,3887575.820,68.547
08x,,479951.287,3888952.201,72.745
E1,,480088.803,3888731.292,76.387
E2,,480082.324,3888730.861,76.495
E3,,480073.485,3888726.782,76.411
E4,,480074.825,3888731.402,76.823
E5,,480068.179,3888727.497,76.324
E6,,480060.785,3888722.037,75.839
E7,,480050.528,3888717.016,75.593
E8,,480042.342,3888714.512,75.421
E9,,480030.712,3888710.879,75.806
错误内容:提示内存错误,但不懂,求详细解答 谢谢