有以下程序
#include
main()
{ FILE *fp;
int a[10]={1,2,3,0,0}, i;
fp = fopen("d2.dat", "wb");
fwrite(a, sizeof(int), 5, fp);
fwrite(a, sizeof(int), 5, fp);
fclose(fp);
fp = fopen("d2.dat", "rb");
fread(a, sizeof(int), 10, fp);
fclose(fp);
for (i=0; i<10; i++)
printf("%d,", a[i]);
}
程序的运行结果是
- A.1,2,3,0,0,0,0,0,0,0,
- B.1,2,3,1,2,3,0,0,0,0,
- C.123,0,0,0,0,123,0,0,0,0,
- D.1,2,3,0,0,1,2,3,0,0,
热度🔥966
解析:打开微信小程序查看本题解析