请编写函数,从文件中读出文章,将其输出到屏幕上。

函数原型

void ReadArticle(FILE *f);

说明:参数 f 为文件指针。函数读出 f 所指示文件中的文章,将其输出到屏幕上。

裁判程序

#include <stdio.h>
#include <stdlib.h> void ReadArticle(FILE *f); int main()
{
FILE *f;
f = fopen("Article.txt", "r");
if (!f)
{
puts("文件无法打开!");
exit(1);
} ReadArticle(f); if (fclose(f))
{
puts("文件无法关闭!");
exit(1);
}
return 0;
} /* 你提交的代码将被嵌在这里 */

答案:

void ReadArticle(FILE *f)
{
int ch;
while(!feof(f))
{
ch = getc(f);
if(ch == EOF)
break;
else
putc(ch,stdout);
}
}

最新文章

  1. lustre文件系统部署流程
  2. flush vs ob_flush
  3. ahjesus SSHkey登陆linux服务器,无需密码,ubuntu
  4. 钉子和小球_DP
  5. C语言的字符测试函数
  6. Unity 使用实体类
  7. Eclipse中Ctrl+Alt+Down和Ctrl+Alt+Up不起作用
  8. Python之while循环
  9. BFC和清除浮动
  10. Back-off pulling image \&quot;registry.access.redhat.com/rhel7/pod-infrastructure:latest
  11. SQL查看死锁+清理死锁
  12. 数组 this.setData快捷赋值
  13. flask run方法和run_simple
  14. JDK1.6新特性,WebService强化
  15. [笔记] FreeBSD使用小技巧
  16. 数据库引擎InnoDB和MyISAM区别
  17. .net中session的使用
  18. tbnet编译
  19. MySQL协议分析(2)
  20. hadoop2.2.0编译、安装和测试

热门文章

  1. Python 字典是如何解决哈希冲突的
  2. [BUUCTF]REVERSE——[ACTF新生赛2020]rome
  3. LuoguP7375 [COCI2018-2019#5] Jarvis 题解
  4. Android NDK开发篇:Java与原生代码通信(异常处理)
  5. java源码——对文件内容的查找和替换(开始写界面咯)
  6. 【LeetCode】1023. Camelcase Matching 解题报告(Python)
  7. 【LeetCode】980. Unique Paths III解题报告(C++)
  8. 【LeetCode】831. Masking Personal Information 解题报告(Python)
  9. LeetCode118. Pascal&#39;s Triangle 杨辉三角
  10. CAS学习笔记一:CAS 授权服务器简易搭建