当前位置:网站首页>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();
}
}边栏推荐
- Database backup (MySQL)
- Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?
- Oracle database merge row records, wmsys WM_ Use of the concat function and group in MySQL_ Use and comparison of concat (ID).
- LeetCode——42. Connected to rainwater (double pointer)
- Center detection of circular marking points for opencv camera calibration
- ffmpeg硬件编解码Nvidia GPU
- LeetCode-1005. Maximized array sum after K negations
- 论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
- The use of histogram function in MATLAB
- LeetCode-384. 打乱数组
猜你喜欢

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

《DAMA数据管理知识体系指南》:章节分值占比

Activity | authing's first channel cooperation activity came to a successful conclusion

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

LeetCode——42. Connected to rainwater (double pointer)

使用exe4j 将.jar文件打包为.exe文件

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

C语言:使用.h和.c文件遇到的问题总结

Authing Share|理解 SAML2 协议

Recyclerview cache reuse analysis, source code interpretation
随机推荐
TypeScript学习笔记(二)
信息安全数学基础 Chapter 1——整除
LeetCode——42. Connected to rainwater (double pointer)
TestPattern error
Qlineedit set input mask
GemBox. Bundle 43.0 Crack
使用exe4j 将.jar文件打包为.exe文件
自动化测试-Selenium
从制造到“智造”,探索制造企业破局之道
Authing biweekly news: authing forum launched (4.25-5.8)
Guide to Dama data management knowledge system: percentage of chapter scores
sql server中移除key lookup书签查找
From a "trendsetter" to a "wind chaser", can master Kang still lead the market?
Xie Yang, CEO of authing, was selected into Forbes' 30 under 30 Asia list in 2021
Leetcode力扣刷题
DFS and BFS notes (I) breadth first search based on C language
Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“
通过Xshell连接有跳板机/堡垒机的服务器
error:指针作为函数参数错误总结
Oracle analysis function over and MySQL achieve similar effects