函数filecopy的功能是,将fin所指文件中的内容输出到fout所指文件中,但函数不完整: void filecopy( FILE *fin,FILE *fout) { char ch; ch=getc(fin); while(________________) { putc(ch,fout); ch=getc(fin); } }其中下划线处应填入的是
!feof(fin)
举一反三
- 以下程序企图把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符#号时结束输入和输出操作,但程序有错。 #include"stdio.h" main() { FILE *fout; char ch; fout=fopen('abc.txt', 'w'); ch=fgetc(stdin); while(ch!= '#') { fputc(ch,fout); ch =fgetc(stdin); } fclose(fout); } 出错的原因是
- 以下程序希望把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符#号时结束输入和输出操作,但程序有错。出错的原因是#include int main(){ FILE *fout; char ch; fout=fopen(abc.txt,w); if (fout == NULL) { printf(cannot open infile. ); exit(0); } ch=fgetc(stdin); while(ch!=#) { fputc(ch,fout); ch=fgetc(stdin); } fclose(fout); return 0;}
- 中国大学MOOC: 以下程序希望把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符#号时结束输入和输出操作,但程序有错。出错的原因是#include int main(){ FILE *fout; char ch; fout=fopen(abc.txt,w); if (fout == NULL) { printf(cannot open infile. ); exit(0); } ch=fgetc(stdin); while(ch!=#) { fputc(ch,fout); ch=fgetc(stdin); } fclose(fout); return 0;}
- 【13.4】 以下程序企图把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符#号时结束输入和输出操作,但程序有错。 main( )[br][/br] { FILE *fout; char ch; fout=fopen('abc.txt','w'); ch=fgetc(stdin); while(ch!='#') { fputc(ch,fout); ch=fgetc(stdin); } fclose(fout); } 出错的原因是( ) A: 输入文件没有关闭 B: 函数fgetc调用形式错误 C: 函数fopen调用形式错误 D: 文件指针stdin没有定义
- 若有定义:char ch,*p=&ch;通过指针p用格式输出函数输出ch中字符的语句是______。
内容
- 0
如果输入为:ABCdef 执行下面一段程序后,则输出为: void main( ) {char ch; while((ch=getchar( ))!=' ') { if(ch > ='A' && ch < ='Z') ch=ch+32; else if(ch > ='a' && ch < 'z') ch=ch-32; printf("%c",ch); } printf(" "); }
- 1
哪一个命令能用来删除当前目录及其子目录下名为‘Core’的文件?() A: fin B: -nAmeCore-exeCrm; C: fin D: -nAmeCore-exeCrm{}\; E: fin F: -nAmeCore-exeCrm{}-; G: fin H: -nAmeCore-exeCrm{}。
- 2
文件输出字节流对象fout已成功创建;对fout进行过滤,即在fout的基础上声明并创建数据输出流DataOutputStream对象dout,下列语句完整、正确的是?
- 3
若文件指针fp已正确指向文件,ch为字符型变量,以下不能把字符输出到文件中的语句是( )。 A: fget(fp,ch); B: fputc(ch,fp); C: fprintf(fp,”%c”,ch); D: fwrite(&ch,sizeof(ch),1,fp);
- 4
若文件指针fp已正确指向文件,ch为字符型变量,以下不能把字符输出到文件中的语句是()。 A: fget(f0,ch); B: foutc(ch,fo); C: fprinff(fp,”%c”,ch); D: fwrite(&ch,sizeof(ch),1,fp);