有以下程序 (a123.txt在当前盘符下已经存在)#include "stdio.h"void main(){ FILE *fp; int a[10],*p=a; fp=fopen("a123.txt","w"); while( strlen(gets(p))0 ) { fputs(a,fp); fputs("\n",fp); } fclose(fp);} 程序实现的功能是A.从键盘输入若干行字符,按行号倒序写入文本文件a123.txt中B.从键盘输入若干行字符,取前两行写入文本文件a123.txt中C.从键盘输入若干行字符,第一行写入文本文件a123.txt中D.从键盘输入若干行字符,依次写入文本文件a123.txt中
有以下程序 (a123.txt在当前盘符下已经存在)#include "stdio.h"void main(){ FILE *fp; int a[10],*p=a; fp=fopen("a123.txt","w"); while( strlen(gets(p))>0 ) { fputs(a,fp); fputs("\n",fp); } fclose(fp);} 程序实现的功能是A.从键盘输入若干行字符,按行号倒序写入文本文件a123.txt中B.从键盘输入若干行字符,取前两行写入文本文件a123.txt中C.从键盘输入若干行字符,第一行写入文本文件a123.txt中D.从键盘输入若干行字符,依次写入文本文件a123.txt中
相关考题:
阅读下面程序,程序实现的功能是(a123.txt在当前盘符下已经存在)#include "stdio.h"void main(){FILE *fp;int a[10],*p=a;fp=fopen("a123.txt","w");while( strlen(gets(p))0 ){ fputs(a,fp);fputs("\n",fp);}fclose(fp);}A.从键盘输入若干行字符,按行号倒序写入文本文件a123.txt中B.从键盘输入若干行字符,取前2行写入文本文件a123.txt中C.从键盘输入若干行字符,第一行写入文本文件a123.txt中D.从键盘输入若干行字符,依次写入文本文件a123.txt中
假定当前盘符下有两个如下文本文件:文件名 a1.txt a2.txt内容 123# 321#则下面程序段执行后的结果为#include "stdio.h"void fc(FILE *p){ char c;while((c=fgetc(p))!=′#′)putchar(c);}main(){ FILE *fp;fp=fopen("a1.txt","r");fc(fp);fclose(fp);fp=fopen("a2.txt","r");fc(fp);fclose(fp);putchar('\n');}A.123321B.123C.321D.以上答案都不正确
有以下程序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' 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,
假定当前盘符下有两个如下文本文件: 文件名 a1.txt a2.txt 内容 123# 321# 则下面程序段执行后的结果为 #include"stdio.h" void fc(FILE*p) { charc; while((c=fgetc(p))!='#')putchar(c);} main() { FILE*fp; fp=fopen("a1.txt","r"); fc(fp); fclose(fp);A.123321B.123C.321D.以上答案都不正确
有以下程序includevoid WriteStr(char*fn,char*str){FILE*fp; fp=fopen(fn,"w");fputs 有以下程序 #include<stdio.h> void WriteStr(char*fn,char*str) { FILE*fp; fp=fopen(fn,"w");fputs(str,fp);fclose(fp); } main() { writeStr("t1.dat","start"); WriteStr("t1.dat","end"); } 程序运行后,文件t1.dat中的内容是A.startB.endC.startendD.endrt
有以下程序 include void WriteStr(char*fn,char*str) {FILE*fp; fp=f 有以下程序 #include<stdio.h> void WriteStr(char*fn,char*str) {FILE*fp; fp=fopen(fn"w");fputs(str,fp);fclose(fp); } main() { WriteStr("t1.dat"start"); WriteStr("t1,dat","end"); } 程序运行后,文件t1.dat中的内容是 ______。A.startB.endC.startendD.endrt
假定当前盘符下有两个如下文本文件: 文件名 a1.txt a2.txt 内容 123# 321# 则下面程序段执行后的结果为 #include "stdio.h" void fc(FILE *p) { char c; while((c=fgetc(p))!='#')putchar(c);} main() { FILE *fp; fp=fopen("a1.txt","r"); fc(fp); fclose(fp); fp=fopen("a2.txt","r"); fc(fp); fclose(fp); putchar('\n');}A.123321B.123C.321D.以上答案都不正确
在C中,打开文件的程序段中正确的是A.#include <stdio.h> FILE *fp; fp=fopen("file1.c","WB");B.#include <stdio.h> FILE fp; fp=fopen("file1.c","w");C.#include <stdio.h> FILE *fp; fp=fopen("file1.c","w");D.#include <string.h> FILE *fp; fp=fopen("file1.c","w");