当前位置:网站首页>6-3 读文章(*)
6-3 读文章(*)
2022-06-11 17:17:00 【西红柿_码农】
6-3 读文章(*)
分数 10
全屏浏览题目
切换布局
作者 李祥
单位 湖北经济学院
请编写函数,从文件中读出文章,将其输出到屏幕上。
函数原型
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;
}
/* 你提交的代码将被嵌在这里 */输入样例
Poor Old Gentleman
An old gentleman was walking slowly along a street one day when he saw a little
boy who was trying to reach a doorbell which was too high for him. He was a
kind-hearted old man, so he stopped and said, "I will ring the bell for you,"
and then he pulled the bell so hard that it could be heard all over the house.
The little boy looked up at him and said, "Now we will run away. Come on." And
before the old gentleman knew what was happening, the naughty boy had run round
the corner of the street, leaving the man to explain to the angry owner of the
house why he had rung the bell.
提示:最后一行输入完以后打回车键,在下一行的开头按下 Ctrl + Z (屏幕显示为 ^Z),然后再打回车键结束输入。
输出样例
文件保存成功!
打开“Article.txt”文件,查看文件内容。
Article.txt
Poor Old Gentleman
An old gentleman was walking slowly along a street one day when he saw a little
boy who was trying to reach a doorbell which was too high for him. He was a
kind-hearted old man, so he stopped and said, "I will ring the bell for you,"
and then he pulled the bell so hard that it could be heard all over the house.
The little boy looked up at him and said, "Now we will run away. Come on." And
before the old gentleman knew what was happening, the naughty boy had run round
the corner of the street, leaving the man to explain to the angry owner of the
house why he had rung the bell.void WriteArticle(FILE *f){
char data;
data=getchar();
while(data!=EOF){
fputc(data,f);
data=getchar();
}
}边栏推荐
- Oracle analysis function over and MySQL achieve similar effects
- The use of histogram function in MATLAB
- 信息安全数学基础 Chapter 1——整除
- 信息安全数学基础 Chapter 3——有限域(一)
- 搜狐全員遭詐騙,暴露哪些問題?
- Bentley 使用 Authing 快速实现应用系统与身份的集成
- 满k叉树编号为 i 的节点的孩子编号公式推导
- Katalon Studio Enterprise
- Authing 双周动态:Authing 论坛上线(4.25-5.8)
- Authing CEO 谢扬入选福布斯 2021 年 30 Under 30 亚洲榜单
猜你喜欢

Science popularization genius on the left, madman on the right

How does Sister Feng change to ice?

ffmpeg奇偶场帧Interlace progressive命令和代码处理

Real time myth -- real-time RTOS multitask performance analysis

Learning C language from scratch day 039

DFS和BFS笔记(一)基于C语言的广度优先搜索

Authing Share|理解 SAML2 协议

RecyclerView缓存复用解析,源码解读

GemBox. Bundle 43.0 Crack

《DAMA数据管理知识体系指南》:章节分值占比
随机推荐
Classification and method of feature fusion
ffmpeg硬编解码 Inter QSV
Leetcode 450. Deleting a node in a binary search tree
Pychart tips - how to set up a background picture
Create database instance
闭包的简单理解
Bentley uses authing to quickly integrate application system and identity
What products are good for cross-border e-commerce? What are the top selling categories?
LeetCode-384. Scramble array
Connection and difference of network streaming media protocol (RTP RTCP RTMP HLS)
论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
“is-a”,“has-a”,“like-a”
信息安全数学基础 Chapter 3——有限域(二)
What problems are exposed when all Sohu employees are cheated?
端口规划与APJ
threejs中设置物体的贴图+场景的6面贴图 +创建空间
Derivation of child numbering formula for nodes numbered I in full k-ary tree
信息安全数学基础 Chapter 3——有限域(一)
C语言:使用.h和.c文件遇到的问题总结
av_read_frame返回值为-5 Input/output error