for(n=0;!feof(fp)&&fread(&tongxun[n],sizeof(structtongxunlu),1,fp);n++);是什么意思?
举一反三
- 有以下程序: #include <stdio.h> main() { FILE*fp; int i,a[6] = {1,2,3,4,5,6},k; fp = fopen("data.dat", "w+b"); fwrite(&a[0],sizeof(int),1,fp); for(i=1; i<6; i++) { fseek(fp, 0L, 0); fread(&k, sizeof(int), 1, fp); fseek(fp, 0L, 0); a[i] +=k; fwrite(&a[i], sizeof(int), 1, fp); } rewind(fp); fread(&k, sizeof(int), 1, fp); fclose(fp); printf("%d\n",k); } 程序的运行结果是______。[/i][/i] A: 21 B: 6 C: 123456 D: 11
- 假设所有用到的函数都能正确执行,则下面说法正确的是 A: fread(&n,4,1,fp)和fread(&n,1,4,fp)完全等价 B: 使用fread(&n,4,1,fp)读一个整数或使用fread(&n,1,4,fp)读一个整数,读取后n中的值相同 C: fread(&n,4,1,fp)和fread(&n,1,4,fp)两种用法的返回值相同 D: 其他几种说法都不对
- 有以下程序#include "stdio.h"main(){ FILE *fp; int i, a[6] = {1,2,3,4,5,6}, k; fp = fopen("data.dat", "w+b"); fwrite(&a[0], sizeof(int), 1, fp); for (i=1; i<6; i++) { fseek(fp, 0L, 0); fwrite(&a[i], sizeof(int), 1, fp); } fseek(fp, 0L, 0); fread(&k, sizeof(int), 1, fp); fclose(fp); printf("%d\n", k);}程序运行后的输出结果是______。[/i] A: 6 B: 21 C: 123456 D: 654321
- 有以下程序:#include [stdio.h] main() { FILE *fp; int a[10]={1,2,3}, i, n; fp = fopen("d1.dat", "w"); for (i=0; i<3; i++) fprintf(fp, "%d", a[i]); fprintf(fp, "\n"); fclose(fp); fp = fopen("d1.dat", "r"); fscanf(fp, "%d", &n); fclose(fp); printf("%d\n", n); }程序的运行结果是()。[/i] A: 321 B: 12300 C: 1 D: 123
- 有以下程序:#include [stdio.h]main(){ FILE *fp; int a[10]={1,2,3}, i, n;fp = fopen("d1.dat", "w");for (i=0; i<3; i++) fprintf(fp, "%d", a[i]);fprintf(fp, "\n");fclose(fp);fp = fopen("d1.dat", "r");fscanf(fp, "%d", &n);fclose(fp);printf("%d\n", n);}程序的运行结果是()。[/i] A: 321 B: 12300 C: 1 D: 123