当前位置:网站首页>6-3 reading articles (*)
6-3 reading articles (*)
2022-06-11 17:37:00 【Tomatoes_ Menon】
Please write a function , Read the article from the file , Output it to the screen .
The function prototype
void ReadArticle(FILE *f);explain : Parameters f For file pointer . Function read out f Articles in the indicated file , Output it to the screen .
judging procedures
#include <stdio.h>
#include <stdlib.h>
void ReadArticle(FILE *f);
int main()
{
FILE *f;
f = fopen("Article.txt", "r");
if (!f)
{
puts(" The file could not be opened !");
exit(1);
}
ReadArticle(f);
if (fclose(f))
{
puts(" File cannot be closed !");
exit(1);
}
return 0;
}
/* The code you submit will be embedded here */open Windows Notepad software for , Copy the text below , Save the file and name it “Article.txt”.
Article.txt
A Cure for a Headache
One day a man went into a chemist's shop and said, "Have you anything to cure a
headache?"
The chemist took a bottle from a shelf, held it under the gentleman's nose and
took out the cork. The smell was so strong that tears came into the man's eyes
and ran down his cheeks.
"What did you do that for?" he said angrily, as soon as he could get back his
breath.
"But that medicine has cured your headache, hasn't it?" said the chemist.
"You fool," said the man, "It's my wife that has the headache, not me!"
sample input
( nothing )
sample output
A Cure for a Headache
One day a man went into a chemist's shop and said, "Have you anything to cure a
headache?"
The chemist took a bottle from a shelf, held it under the gentleman's nose and
took out the cork. The smell was so strong that tears came into the man's eyes
and ran down his cheeks.
"What did you do that for?" he said angrily, as soon as he could get back his
breath.
"But that medicine has cured your headache, hasn't it?" said the chemist.
"You fool," said the man, "It's my wife that has the headache, not mevoid ReadArticle(FILE *f){
char ch;
while((ch=fgetc(f))!=EOF){
printf("%c",ch);
}
}边栏推荐
- 信息安全数学基础 Chapter 4——二次剩余与方根
- What subclasses inherit, polymorphism, and upward transformation
- 关于元素位置和尺寸
- vscode保存代码时自动eslint格式化
- 【题解】Codeforces Round #798 (Div. 2)
- 05_特征工程—降维
- Dynamic: capturing network dynamics using dynamic graph representation learning
- Mathematical foundations of information security Chapter 3 - finite fields (I)
- 6-2 多个整数的逆序输出-递归
- ForEach遍历集合、 集合容器
猜你喜欢

Test basis: black box test

Service learning notes 01 start method and life cycle

Connect the server with springboard / fortress through xshell

拜登下令强制推行零信任架构

定制 or 订阅?未来中国 SaaS 行业发展趋势是什么?

04_ Feature engineering feature selection

测试基础之:黑盒测试

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

MFSR:一种新的推荐系统多级模糊相似度量

活动 | Authing 首次渠道合作活动圆满落幕
随机推荐
ffmpeg硬编解码 Inter QSV
论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
Foreach traverses collections and collection containers
Recyclerview cache reuse analysis, source code interpretation
How to simplify a lot of if... Elif... Else code?
av_read_frame返回值为-5 Input/output error
CLP information -5 keywords to see the development trend of the financial industry in 2022
【线上问题】Timeout waiting for connection from pool 问题排查
Authing 背后的计算哲学
Merge two ordered linked lists ---2022/02/24
Chapter II relational database
通过Xshell连接有跳板机/堡垒机的服务器
7-2 h0107. Pig-Latin
Don't you understand the design and principle of thread pool? Break it up and crush it. I'll teach you how to design the thread pool
聚类方法汇总
05_ Feature Engineering - dimension reduction
spawn ./gradlew EACCES at Process.ChildProcess._handle.onexit
sql server中关于FORCESCAN的使用以及注意项
合并K个升序链表---2022/02/26
括号生成---2022/02/25