题目内容

有以下程序#includemain(){inti;FILE*fp;for(i=0;i<3;i++){fp=fopen("res.txt","w");fputc('K'+i,fp);fclose(fp);}}程序运行后,在当前目录下会生成一个res.txt文件,其内容是

A. EOF
B. M
C. KLM
D. L

查看答案
更多问题

有以下程序#includemain(){FILE*fp;inti,a[6]={1,2,3,4,5,6},k;fp=fopen("data.dat","w+");fprintf(fp,"%d\n",a[0]);for(i=1;i<6;i++){rewind(fp);fprintf(fp,"%d\n",a[i]);}rewind(fp);fscanf(fp,"%d",&k);fclose(fp);printf("%d\n",k);}程序运行后的输出结果是

A. 6
B. 21
C. 123456
D. 654321

有以下程序#includemain(){FILE*fp;inti,a[6]={1,2,3,4,5,6},k;fp=fopen("data.dat","w+");for(i=0;i<6;i++)fprintf(fp,"%d\n",a[5-i]);rewind(fp);for(i=0;i<6;i++){fscanf(fp,"%d",&k);printf("%d,",k);}fclose(fp);}程序运行后的输出结果是

A. 6,5,4,3,2,1,
B. 1,2,3,4,5,6,
C. 1,1,1,1,1,1
D. 6,6,6,6,6,6,

有以下程序#includemain(){FILE*fp;inta[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,

以下程序依次把从终端输入的字符存放到f文件中,用#作为结束输入的标志,则在横线处应填入的选项是#includemain(){FILE*fp;charch;fp=fopen("fname","w");while((ch=getchar())!='#')fputc(__________);fclose(fp);}

A. ch,"fname"
B. fp,ch
C. ch
D. ch,fp

答案查题题库