【计算机类职业资格】文件(一)及答案解析.doc

上传人:dealItalian200 文档编号:1335821 上传时间:2019-10-17 格式:DOC 页数:3 大小:32KB
下载 相关 举报
【计算机类职业资格】文件(一)及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】文件(一)及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】文件(一)及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、文件(一)及答案解析(总分:10.00,做题时间:90 分钟)一、B选择题/B(总题数:4,分数:4.00)1.fread(buf,32,2,fp)的功能是_。(分数:1.00)A.从 fp文件流中读出整数 32,存放在 buf中B.从 fp文件流中读出 32个字节的字符,存放在 buf中C.从 fp文件流中读出整数 32和 2,存放在 buf中D.从 fp文件流中读出 2块 32个字节的字符,存放在 buf中2.有以下程序 #include void WriteStr(char*fn,char*str) FILE*fp; fp=fopen(fn,“w“);fputs (str,fp);fcl

2、ose(fp); main() WriteStr(“t1.dat“,“start“); WriteStr(“t1dat“,“end“); 程序运行后,文件 t1.dat中的内容是_。(分数:1.00)A.startB.endC.startendD.endrt3.以下与函数 fseek(fp,OL,SEEK_SET)有相同作用的是_。(分数:1.00)A.feof(fB.ftell(fC.fgetc(fD.rewind(f4.有以下程序 #include stdio.h main() FILE *fp1; fp1=fopen(“f1.txt“,“w“); fprintf(fp1,“abc“);

3、fclose(fp1); 若文本文件 f1.txt中原有内容为:good,则运行以上程序后,文件 n.txt中的内容为_。(分数:1.00)A.goodabcB.abcdC.abcD.abcgood二、B填空题/B(总题数:3,分数:6.00)5.以下程序中用户由键盘输入一个文件名,然后输入一串字符(用$结束输入)存放到此文件中,形成文本文件,并将字符的个数写到文件尾部。请填空。 #include string.h main() FILE*fp: char ch,fname32 int count=0: prinft(“input the filename:“): scanf(“%s“,fna

4、me); if(fp=fopen(_,“w+“)=NULL) printf(“cant open file:%s/n“,fname); exit(0): printf(“enter data:/n“): while(ch=getchar()!=) fputc(ch,fp): count+; fprintf(_,“/n%d/n“, count); fclose(fp): (分数:2.00)填空项 1:_6.以下程序可将磁盘中的一个文件复制到另一个文件中,两个文件的文件名在可执行命令的命令行中(相当于 COPY命令),假定文件在当前目录下。 #include stdio.h void main(i

5、nt argc,char *argv) FILE*f1*f2; if(argc_) printf(“parameter error!/n“);exit(0); f1=fopen(argv1,“r“); f2=fopen(argv2,“w“); while(_)fputc (fgetc (f1),f2); fclose(f1): fclose(f2);(分数:2.00)填空项 1:_7.下列程序是处理 C盘根目录下的 a.txt文件,统计该文件中字符的个数。请填空,使程序完整。 #include stdio.h main() FILE*fp;char ch; long num=0; if(_)

6、printf(“Cant open file !/n“); exit(0); while(_) ch=fgetc(fp); _; printf(“%d“,num); fclose(fp); (分数:2.00)填空项 1:_文件(一)答案解析(总分:10.00,做题时间:90 分钟)一、B选择题/B(总题数:4,分数:4.00)1.fread(buf,32,2,fp)的功能是_。(分数:1.00)A.从 fp文件流中读出整数 32,存放在 buf中B.从 fp文件流中读出 32个字节的字符,存放在 buf中C.从 fp文件流中读出整数 32和 2,存放在 buf中D.从 fp文件流中读出 2块

7、32个字节的字符,存放在 buf中 解析:2.有以下程序 #include void WriteStr(char*fn,char*str) FILE*fp; fp=fopen(fn,“w“);fputs (str,fp);fclose(fp); main() WriteStr(“t1.dat“,“start“); WriteStr(“t1dat“,“end“); 程序运行后,文件 t1.dat中的内容是_。(分数:1.00)A.startB.end C.startendD.endrt解析:3.以下与函数 fseek(fp,OL,SEEK_SET)有相同作用的是_。(分数:1.00)A.feof

8、fB.ftell(fC.fgetc(fD.rewind(f 解析:4.有以下程序 #include stdio.h main() FILE *fp1; fp1=fopen(“f1.txt“,“w“); fprintf(fp1,“abc“); fclose(fp1); 若文本文件 f1.txt中原有内容为:good,则运行以上程序后,文件 n.txt中的内容为_。(分数:1.00)A.goodabcB.abcdC.abc D.abcgood解析:二、B填空题/B(总题数:3,分数:6.00)5.以下程序中用户由键盘输入一个文件名,然后输入一串字符(用$结束输入)存放到此文件中,形成文本文件,并

9、将字符的个数写到文件尾部。请填空。 #include string.h main() FILE*fp: char ch,fname32 int count=0: prinft(“input the filename:“): scanf(“%s“,fname); if(fp=fopen(_,“w+“)=NULL) printf(“cant open file:%s/n“,fname); exit(0): printf(“enter data:/n“): while(ch=getchar()!=) fputc(ch,fp): count+; fprintf(_,“/n%d/n“, count);

10、fclose(fp): (分数:2.00)填空项 1:_ (正确答案:fname, fp)解析:6.以下程序可将磁盘中的一个文件复制到另一个文件中,两个文件的文件名在可执行命令的命令行中(相当于 COPY命令),假定文件在当前目录下。 #include stdio.h void main(int argc,char *argv) FILE*f1*f2; if(argc_) printf(“parameter error!/n“);exit(0); f1=fopen(argv1,“r“); f2=fopen(argv2,“w“); while(_)fputc (fgetc (f1),f2); f

11、close(f1): fclose(f2);(分数:2.00)填空项 1:_ (正确答案:3, !feof(f1))解析:7.下列程序是处理 C盘根目录下的 a.txt文件,统计该文件中字符的个数。请填空,使程序完整。 #include stdio.h main() FILE*fp;char ch; long num=0; if(_) printf(“Cant open file !/n“); exit(0); while(_) ch=fgetc(fp); _; printf(“%d“,num); fclose(fp); (分数:2.00)填空项 1:_ (正确答案:(fp=fopen(“c:/a.txt“),“r“)=NULL , !feof (fp) ,fputc (ch,fp);)解析:

展开阅读全文
相关资源
猜你喜欢
  • BS DD IEC PAS 61249-6-3-2011 Specification for finished fabric woven from  E  glass for printed boards《印制板 E 玻璃制成的成品纤维织品规范》.pdf BS DD IEC PAS 61249-6-3-2011 Specification for finished fabric woven from E glass for printed boards《印制板 E 玻璃制成的成品纤维织品规范》.pdf
  • BS DD IEC PAS 61280-2-10-2003 Fibre optic communication subsystem test procedures - Digital systems - Time-resolved chirp and alpha-factor measurement of laser transmitters《纤维光学通信子.pdf BS DD IEC PAS 61280-2-10-2003 Fibre optic communication subsystem test procedures - Digital systems - Time-resolved chirp and alpha-factor measurement of laser transmitters《纤维光学通信子.pdf
  • BS DD IEC PAS 62282-6-150-2011 Fuel cell technologies Micro fuel cell power systems Safety Water reactive (UN Division 4 3) compounds in indirect PEM fuel cells《燃料电池技术 微型燃料电池动力系统 安.pdf BS DD IEC PAS 62282-6-150-2011 Fuel cell technologies Micro fuel cell power systems Safety Water reactive (UN Division 4 3) compounds in indirect PEM fuel cells《燃料电池技术 微型燃料电池动力系统 安.pdf
  • BS DD IEC PAS 62326-14-2010 Printed boards Device embedded substrate Terminology  reliability  design guide《印刷电路板 设备嵌入式基底 术语 可靠性 设计指南》.pdf BS DD IEC PAS 62326-14-2010 Printed boards Device embedded substrate Terminology reliability design guide《印刷电路板 设备嵌入式基底 术语 可靠性 设计指南》.pdf
  • BS DD IEC PAS 62326-7-1-2007 Performance guide for single- and double-sided flexible printed wiring boards《单面和双面柔性印制布线电路板的性能指南》.pdf BS DD IEC PAS 62326-7-1-2007 Performance guide for single- and double-sided flexible printed wiring boards《单面和双面柔性印制布线电路板的性能指南》.pdf
  • BS DD IEC PAS 62435-2006 Electronic components - Long duration storage of electronic components - Guidance for implementation《电子部件 电子元件的长期存储 执行指南》.pdf BS DD IEC PAS 62435-2006 Electronic components - Long duration storage of electronic components - Guidance for implementation《电子部件 电子元件的长期存储 执行指南》.pdf
  • BS DD IEC PAS 62437-2006 Radio disturbance characteristics for the protection of receivers used on board vehicles boats and on devices - Limits and methods of measurement - Specifi.pdf BS DD IEC PAS 62437-2006 Radio disturbance characteristics for the protection of receivers used on board vehicles boats and on devices - Limits and methods of measurement - Specifi.pdf
  • BS DD IEC PAS 62443-3-2008 Security for industrial process measurement and control - Network and system security《工业过程的测量和控制安全 网络和系统安全》.pdf BS DD IEC PAS 62443-3-2008 Security for industrial process measurement and control - Network and system security《工业过程的测量和控制安全 网络和系统安全》.pdf
  • BS DD IEC PAS 62473-2007 Clothes washing machines for household use - Methods for measuring the mechanical action in household washing machines《家用洗衣机 家用洗衣机机械作用的测量方法》.pdf BS DD IEC PAS 62473-2007 Clothes washing machines for household use - Methods for measuring the mechanical action in household washing machines《家用洗衣机 家用洗衣机机械作用的测量方法》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1