一维数组数据的读写中的问题~
请大家讲解下红色的部分。尤其fprintf(fp,"%d,",a[i]);%d后为什么要加,才能出正确结果...#include "time.h"
#include "stdlib.h"
#include "stdio.h"
#define N 20
main()
{
int a[N],b[N],i,*p=b;
FILE *fp;
randomize();
for(i=0;i<N;i++)
a[i]=10+random(90);
for(i=0;i<N;i++)
printf("%d\t",a[i]);
printf("\n");
fp=fopen("data1.dat","wb");
for(i=0;i<N;i++)
fprintf(fp,"%d,",a[i]);
fclose(fp);
fp=fopen("data1.dat","rb");
while(!feof(fp))
fscanf(fp,"%d,",p++);
fclose(fp);
for(i=0;i<N;i++)
printf("%d\t",b[i]);
getch();
}
[ 本帖最后由 human84 于 2010-1-30 13:51 编辑 ]