单选题有以下程序#include main(){ int i; FILE* fp; for (i=0; i5;i++) {  fp = fopen(output.txt, w);  fputc('K'+ i, fp);  fclose(fp); }}程序运行后,在当前目录下会生成一个output.txt文件,其内容是(  )。AEBEOFCABCDEDA

单选题
有以下程序#include main(){ int i; FILE* fp; for (i=0; i<5;i++) {  fp = fopen(output.txt, w);  fputc('K'+ i, fp);  fclose(fp); }}程序运行后,在当前目录下会生成一个output.txt文件,其内容是(  )。
A

E

B

EOF

C

ABCDE

D

A


参考解析

解析:
程序执行过程为:i=0时,以只写方式打开一个文本文件output.txt,调用函数fputc向文件输入A,关闭文件;i=1时,再次以只写方式打开output.txt,调用函数fputc向文件输入B覆盖原本的A,关闭文件;之后文件内的值依次为C、D、E,当i=4时,文件内为E,然后关闭文件;i=5退出循环。output.txt文件中内容为E。答案选择A选项。

相关考题:

有以下程序includemain(){FILE*fp;inta[10]={1,2,3},i,n;fp=fopen("d1.daf","w");for( 有以下程序 #include <stdio.h> main() {FILE *fp; int a[10]={1,2,3},i,n; fp=fopen("d1.daf","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);A.12300B.123C.1D.321

有以下程序 include main(){FILE *fp;int i; char ch[]="abcd",t; fp=fopen("abc.dat" 有以下程序 #include <stdio.h> main() {FILE *fp; int i; char ch[]="abcd",t; fp=fopen("abc.dat","wb++"); for(i=O;i<4;i++)fwrite(ch[i],1,1,fp); fseek (fp,-2L,SEEK_END); fread (t,1,1,fp); fclose (fp); printf ("%c\n",t); } 程序执行后的输出结果是______。A.dB.cC.bD.a

有以下程序 include main() { FILE *fp;int i,a[6]={1,2,3,4,5,6}; fp= 有以下程序 #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;i<6;i++)printf("%d,",a[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,

有以下程序:includemain(){FILE *fp;int i,k=0,n=0;fp=fopen("d1.dat","w");for(i=1;i 有以下程序: #include<stdio.h> main() { FILE *fp; int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1;i<4;i++) fprintf(fp,"%d",i); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d%d",k,n); printf("%d %d\n", k,n); fclose(fp); } 执行后输出结果是( )。A.1 2B.123 0C.1 23D.0 0

有下列程序: include main() { FILE *fp; int a[10]={1,2,3},i,n; 有下列程序: #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=open("d1.dat","r"); fscanf(fp,"%d",n); fclose(fp); prinff("%d\n",n); 程序的运行结果是( )。A.12300B.123C.1D.321

有以下程序: include main ( ) int i;for(i =0;i 有以下程序: #include <stdio.h> main ( ) int i; for(i =0;i <3 ;i ++ ) switch (i) case 0: printf(" % d" ,i); case 2: printf(" % d" , i); default: printf( "% d" , i);程序运行后的输出结果是( )。A.22111B.21021C.122D.12

有以下程序:include main(){FILE*fp;int i,k,n; fp=fopen("data.dar","w+");for(i=1;i 有以下程序: #include <stdio.h> main() { FILE *fp; int i,k,n; fp=fopen("data.dar","w+"); for(i=1;i<6;i++) { fprintf(fp,"%d ",i); if(i%3==0) fprintf(fp,"\n"); } rewind(fp); fscanf(fp,"%d%d",k,n); printf("%d%d\n",k,n); fclose(fp); } 程序运行后的输出结果是( )。A.0 0B.123 45C.1 4D.1 2

有以下程序 include main() { FILE *fp; int' a[10]={1,2,3,0,0},i; 有以下程序 #include <stdio.h> 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 = fopenCd2.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,

有以下程序include main(){FILE *fp;int i=20,j=30,k,n;fp=fopen("d1.dat","w");fprin 有以下程序 #include <stdio.h> main() { FILE *fp; int i=20,j=30,k,n; fp=fopen("d1.dat","w"); fprintf(fp,"%d\n",i);fprintf(fp,"%d\n",j); fclose(fp); fp=fopen("d1.dat", "r"); fp=fscanf(fp,"%d%d",k,n); printf("%d%d\n",k,n); fclose(fp); } 程序运行后的输出结果是A.20 30B.20 50C.30 50D.3020

有以下程序:include main( ){FILE * fp; int i,k,n;fp = fopen( "data. dat" ,"w +" ) 有以下程序:#include <stdlo.h>main( ){ FILE * fp; int i,k,n; fp = fopen( "data. dat" ,"w +" ) for(i = 1 ;i<6;i ++ ) { fprintf(fp."% d",i); if(i%3 ==0)fprintf(fp," \n"); } rewind(fp); fscanf(fp." % d% d" ,k, n) ;printf(" % d%d \n" ,k,n); fclose(fp);A.0 0B.123 45C.1 4D.1

有以下程序: include main() {FILE *fp; int i,k,n; fp=fopen("data 有以下程序: #include <stdio.h> main() {FILE *fp; int i,k,n; fp=fopen("data.dat","w+"); for(i=1;i<6;i++) {fprintf(fp,"%d ",i); if(i%3==0) fprintf(fp,"\n"); } rewind(fp); fscanf(fp,"%d%d",k,n); printf("%d %d\n",k,n); fclose(fp); } 程序运行后的输出结果是 ______。A.0 0B.123 45C.1 4D.1 2

有以下程序 include main() { int i,j,m=55; for(i=1;i 有以下程序 #include <stdio.h> main() { int i,j,m=55; for(i=1;i<=3;i++) for(j=3;j<=i;j++) m=m%j; printf("%d\n",m); } 程序的运行结果是A.0B.1C.2D.3

有以下程序:include main ( ){int a[3] [3] , *p,i; p=a[0][0];for(i=0;i 有以下程序: #include <stdio.h> main ( ) { int a[3] [3] , *p,i; p=a[0][0]; for(i=0;i<9; i++)p[i]=i: for(i=0; i<3;i++)Printf("%d",a[1][i]); } 程序运行后的输出结果是( )。A.012B.123C.234D.345

有以下程序:include main()FILE *fp; int i,k=0,n=0;fp=fopen("d1.dat","w");for(i=l 有以下程序: #include <stdio.h> main() FILE *fp; int i, k=0, n=0; fp=fopen("d1.dat","w"); for(i=l;i<4;i++) fprintf(fp,"%d",i); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,'%d%d",k,n); printf("%d %d\n", k, n); fclose(fp); 执行后输出结果是A.1 2B.123 0C.1 23D.0 0

有以下程序include main(){FILE*fp;inti,k,n;fp=fopen("data.dar","w+");for(i=1;i 有以下程序 #include <stdio.h> main() { FILE *fp; int i,k,n; fp=fopen("data.dar", "w+"); for(i=1;i<6;i++) { fprintf(fp,"%d ",1); if(i%3==0) fprintf(fp, "\n"); } rewind(fp); fscanf(fp, "%d%d",k,n); printf. ("%d %d\n",k,n); fclose(fp); } 程序运行后的输出结果是A.0 0B.123 45C.1 4D.1 2

有以下程序:includemain(){FILE*fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1; 有以下程序: #include <stdio.h> main() { FILE *fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1;i<4;i++) fprintf(fp,"%d",i); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d%d",k,n);printf("%d%d\n",k,n); fclose(fp); { 执行后的输出结果是( )。A.1 2B.123 0C.1 23D.0 0

有以下程序:includemain(){FILE*fp;int a[10]={1,2,3},i,n;fp=fopen("d1.dat","w");fo 有以下程序: #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); 程序的运行结果是( )。A.12300B.123C.1D.321

有以下程序include main(){ int.i=0,a=0;while(i 有以下程序 #include <stdio.h> main() { int.i=0,a=0; while(i<20) { for(;;) { if((i%10)==0) break; else i--; } i+=11; a+=i; } printf("%d\n",a) ; } 程序运行后的输出结果是( )A.21B.32C.33D.11

有以下程序 include main( ) { FILE *fp; int i,k=0,n=0; fp=fopen(“d1.dat”, 有以下程序 #include <stdio.h> main( ) { FILE *fp; int i,k=0,n=0; fp=fopen(“d1.dat”,”w”); for(i=1;i<4;i++) fprintf(fp,”%d”,i); fclose(fp); fp=fopen(“d1.dat”,”r”); fscanf(fp,”%d%d”,k,n); printf(“%d %d\n”,k,n); fclose(fp);} 执行后输出结果是( )A.1 2B.123 0C.1 23D.0 0

有以下程序:includemain(){ FILE*fp;int i;char ch[]="abcd",t;fp=fopen("abc.dat","w 有以下程序: #include <stdio.h> main() { FILE *fp; int i; char ch[]="abcd",t; fp=fopen("abc.dat","wb+"); for(i=0;i<4;i++)fwrite(ch[i]1,1,fp); fseck(fp,-2L,SEEK_END) ; fread(t,1,1,fp); felose(fp); printf("%c\n",t); } 程序执行后的输出结果是( )。A.dB.cC.bD.a

有以下程序,程序执行后,输出结果是【】include void fun(int*A) {a[0]=a[1];} main() {i 有以下程序,程序执行后,输出结果是【 】include<stdio.h>void fun(int*A){ a[0]=a[1];}main(){ int a[10]={10,9,8,7,6,5,4,3,2,1,},i;for(i=2;i>1=0;i-) fun(a[i]);for(i=0;i<10;i++) printf("%d,a[i]);printf("\n");}

有以下程序:includemain(){ FILE *fp;int a[10]={1,2,3,0,0},i;fp=fopen("d2.dat","wb 有以下程序: #include<stdio.h> 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,

有以下程序 include main() { FILE*fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i 有以下程序 #include<stdio.h> main() { FILE*fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1;1<4;i++) fprintf(fp,"%d",i); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d%d",k,n); printf("%d%d\n",k,n); fclose(fp); } 执行后输出结果是______。A.1 2B.123 0C.1 2 3D.1 23

若有以下程序 include int a[ ]={2,4,6,8}; main( ) { int i; int *p=a; for(i=0;i 若有以下程序#include <stdio.h>int a[ ]={2,4,6,8};main( ){ int i;int *p=a;for(i=0;i<4;i++) a[i]=*p;printf("%d\n",a[2]);}上面程序的输出结果是A.6B.8C.4D.2

有以下程序 include main( ) { FILE *fp;int i,a[6]={1,2,3,4,5,6}; fp=fopen("d3.da 有以下程序#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;i<6;i++)printf("%d,",a[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 main ( ){int i=0,a=0; while ( i 以下程序输出结果是 #include <stdio.h> main ( ) { int i=0,a=0; while ( i<2 0 ) { for(;;) { if ((i%10) ==0) break; else i--; } i+=11; a+=i; } print f ( "%d\n" , a); }A.21B.32C.33D.11

单选题有以下程序:#include 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,k);}程序的运行结果是(  )。A21B6C123456D11