已知有定义,FILE *fp; char str[] = "Hello!"; fp = fopen("file.dat", "wb");将数组str中存放的字符串写到名为file.dat的二进制文件中。需要的语句是( )。 A: fwrite(str[0], sizeof(char), 1, fp); B: fread(str, sizeof(char), 6, fp); C: fwrite(fp, sizeof(char), 6, str); D: fwrite(str, sizeof(char), 6, fp);
已知有定义,FILE *fp; char str[] = "Hello!"; fp = fopen("file.dat", "wb");将数组str中存放的字符串写到名为file.dat的二进制文件中。需要的语句是( )。 A: fwrite(str[0], sizeof(char), 1, fp); B: fread(str, sizeof(char), 6, fp); C: fwrite(fp, sizeof(char), 6, str); D: fwrite(str, sizeof(char), 6, fp);
若有以下程序: #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
若有以下程序: #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
有以下程序: #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"); 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"); 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); 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
下列程序的输出结果是( ) int main(void) { 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); return 0;}
下列程序的输出结果是( ) int main(void) { 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); return 0;}
有以下程序: #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> 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”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,
以下程序运行后的输出结果是123456,请判断对和错 。#include <;stdio.h>;void main(){ FILE *fp; int x[6]={1,2,3,4,5,6},i;fp=fopen("test.dat","wb");fwrite(x,sizeof(int),3,fp);rewind(fp);fread(x,sizeof(int),3,fp);for(i=0;i<;6;i++)printf("%d",x[i]);printf("\n");fclose(fp);}[/i]
以下程序运行后的输出结果是123456,请判断对和错 。#include <;stdio.h>;void main(){ FILE *fp; int x[6]={1,2,3,4,5,6},i;fp=fopen("test.dat","wb");fwrite(x,sizeof(int),3,fp);rewind(fp);fread(x,sizeof(int),3,fp);for(i=0;i<;6;i++)printf("%d",x[i]);printf("\n");fclose(fp);}[/i]
若有定义FILE*fp,则打开与关闭文件的命令是() A: fopen(fp),fclose(fp) B: fopen(fp,“w”),fclose(fp) C: open(fp),close(fp) D: open(fp,“W”),close(fp)
若有定义FILE*fp,则打开与关闭文件的命令是() A: fopen(fp),fclose(fp) B: fopen(fp,“w”),fclose(fp) C: open(fp),close(fp) D: open(fp,“W”),close(fp)
以只读方式打开一个已存在的文本文件ab.txt,以下选项中正确的是______。A. FILE *fp;fp=fopen("ab.txt","a");B. FILE *fp;fp=fopen("ab.txt","w");C. FILE *fp;fp=fopen("ab.txt","r");D. FILE *fp;fp=fopen("ab.txt","rb+"); A: FILE *fp;fp=fopen("ab.txt","a"); B: FILE *fp;fp=fopen("ab.txt","w"); C: FILE *fp;fp=fopen("ab.txt","r"); D: FILE *fp;fp=fopen("ab.txt","rb+");
以只读方式打开一个已存在的文本文件ab.txt,以下选项中正确的是______。A. FILE *fp;fp=fopen("ab.txt","a");B. FILE *fp;fp=fopen("ab.txt","w");C. FILE *fp;fp=fopen("ab.txt","r");D. FILE *fp;fp=fopen("ab.txt","rb+"); A: FILE *fp;fp=fopen("ab.txt","a"); B: FILE *fp;fp=fopen("ab.txt","w"); C: FILE *fp;fp=fopen("ab.txt","r"); D: FILE *fp;fp=fopen("ab.txt","rb+");