C语言程序设计易晓梅赵芸第10章文件.pptVIP

  • 6
  • 0
  • 约8.95千字
  • 约 68页
  • 2017-11-04 发布于广东
  • 举报

C语言程序设计易晓梅赵芸第10章文件.ppt

PPT研究院 POWERPOINT ACADEMY * * 10.5 实 例 剖 析 exit(0); /*退出程序的运行*/ while((ch=getchar())!=\n) /*直到输入Enter 结束循环*/ putc(ch,fp); /*将输入的字符写入fp所指向的文件*/if(fclose(fp)) /*关闭文件并判断是否成功*/{ puts(File close error); exit(0); } } 10.5 实 例 剖 析 【例10.4】编程实现将文本文件in.txt的内容复制到文本文件out.txt中。 #include stdio.h #include stdlib.h void main() { FILE *in,*out; /*定义文件指针*/ char ch; if((in=fopen(c:\\in.txt,r))==NULL) { printf(InFile open error\n); exit(0); } 10.5 实 例 剖 析 if((out=fopen(c:\\out.txt,w))==NULL) { printf(OutFile open error\n); exit(0);}while(!feof(in)) /*直到文件尾结束循环*/ fputc(fgetc(in),out); /*从文件i

文档评论(0)

1亿VIP精品文档

相关文档