请教!为什么从文件读出数据赋值给数组第一个元素是零
各位高手,我还没用过文件。现在用文件给二维数组,为什么输入数据,运行时除了第一列,每行第一列元素都是零?程序代码:
int i;
float k0,k1,k2,k3;
float a[N][4];
FILE *p;
p=fopen("file","w");
printf("please input the data!\n");
for(i=0;i<N;i++)
{
scanf("%f,%f,%f,%f",&k0,&k1,&k2,&k3);
fprintf(p, "%f,%f,%f,%f",k0,k1,k2,k3);
}
fclose(p);
p=fopen("file","r");
for(i=0;i<N;i++)
{
fscanf(p,"%f,%f,%f,%f",&k0,&k1,&k2,&k3);
a[i][0]=k0;
a[i][1]=k1;
a[i][2]=k2;
a[i][3]=k3;
printf("%f,%f,%f,%f\n",a[i][0],a[i][1],a[i][2],a[i][3]);
}
fclose(p);
----------------解决方案--------------------------------------------------------