若有定义FILE*fp,则打开与关闭文件的命令是()
A: fopen(fp),fclose(fp)
B: fopen(fp,“w”),fclose(fp)
C: open(fp),close(fp)
D: open(fp,“W”),close(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: fclose(*fp) B: close(*fp) C: fclose(fp) D: close(fp)
- 以下程序执行后,文件test.txt的内容是() #include void main() { FILE *fp; fp=fopen(“test.txt”,”w”); fprintf(fp,”%s”,”How ”); fclose(fp); fp=fopen(test.txt“,”a”); fprintf(fp,”%s”,”are you!”); fclose(fp); }
- 若FILE *fp; 关闭文件的语句是: A: close(fp); B: fclose( ); C: fclose(fp); D: close( );
- 以只读方式打开一个已存在的文本文件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+");
- 若要用只读方式打开d:\a.txt文件,则需要执行() A: FILE *fp;fp=fopen(d:\a.txt,r); B: FILE *fp;fp=fopen(d:\\a.txt,r); C: FILE *fp;fp=fopen(d:\a.txt,r+); D: FILE *fp;*fp=fopen(d:\a.txt,w)