有以下程序: #include<stdio.h> main() FILE *fp;int i,a[6]=1,2,3,4,5,6; fp=fopen(“d3.dat”,“w+b”); fwrite(a,sizeof(int),6,fp); fseek(fp,sizeoffint)*3,SEEK SET);/*该语句使读文件的位置指针从文件头向后移动3个int型数据*/ fread(a,sizeoflint),3,fp);fclose(fp); for(i=0;i<6;i++printf("%d,",a[i]); 程序运行后的输出结果是______。[/i]
举一反三
- 有以下程序 #include “stdio.h”int main (void){FILE *fp; int i,a[6]={1,2,3,4,5,6k}; fp=fopen(“d3.dat”,"w+b"); fwrite(a,sizeof(int),6,fp); fseek(fp,sizeof(int)*3,SEEK_SET);/*该语句使读文件的位置指针从文件头向后移动3个int型数据*/ fread(a,sizeof(int),3,fp);fclose(fp); for(i=0;<6;i++) printf("%d"a[i]);return 0;}程序运行结果是[/i] A: 4,5,6,4,5,6, B: 1,2,3,4,5,6, C: 4,5,6,1,2,3, D: 6,5,4,3,2,1,
- 有以下程序 #include<stdio.h> main() {FILE*fp;int i,a[6]={1,2,3,4,5,6}; fp=fopen("d3.dat","w+b"); fwrite(a,sizeof(int),6,fp); fseek(fp,sizeof(int),3,SEEK_SET);/*该语句使读文件的位置指针从文件头向后移动3个int型数据*/ fread(a,sizeof(int),3,fp);fclose(fp); for(i=0 A: 4,5,6,4,5,6, B: 1,2,3,4,5,6, C: 4,5,6,1,2,3, D: 6,5,4,3,2,1,
- 有以下程序#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 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
- 若有以下程序: #include <stdio.h> main( ) { FILE *fp; int i, a[6]={1,2,3,4,5,6},k; fp=fopen("data.dat","w+b"); for(i=0;i<6;i++) {fseek(fp,0L,0); fwrite(&a[5-i],sizeof(int),1,fp); } rewind(fp); fread(&k, sizeof(int),1,fp); fclose(fp); printf("%d",k); } 则程序的输出结果是______。 A: 6 B: 1 C: 123456 D: 21