当前位置:网站首页>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);
}
}边栏推荐
- 定制 or 订阅?未来中国 SaaS 行业发展趋势是什么?
- Mathematical foundations of information security Chapter 3 - finite fields (I)
- threejs利用indexeddb缓存加载glb模型
- Export data prompt -- solution to the problem of secure file priv option
- 括号生成---2022/02/25
- Custom or subscription? What is the future development trend of China's SaaS industry?
- Mathematical basis of information security Chapter 1 - Division
- tidb-cdc日志tables are not eligible to replicate
- MFSR:一种新的推荐系统多级模糊相似度量
- Tidb GC related problems
猜你喜欢

Chapter II relational database

What subclasses inherit, polymorphism, and upward transformation

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

Vscode configures eslint to automatically format an error "auto fix is enabled by default. use the single string form“

05_ Feature Engineering - dimension reduction

Use exe4j to convert The jar file is packaged as Exe file

How to become an optimist organization?

How does Sister Feng change to ice?

【深度学习基础】神经网络的学习(3)

Recyclerview cache reuse analysis, source code interpretation
随机推荐
拜登下令强制推行零信任架构
6-3 读文章(*)
TiDB-unsafe recover(tikv宕机数大于等于一半副本数)
05_特征工程—降维
spawn ./ gradlew EACCES at Process. ChildProcess._ handle. onexit
ffmpeg奇偶场帧Interlace progressive命令和代码处理
Service学习笔记02-实战 startService 与bindService
ffmpeg硬件编解码Nvidia GPU
信息安全数学基础 Chapter 3——有限域(二)
which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod
Speed adjustment of tidb DDL
Activity | authing's first channel cooperation activity came to a successful conclusion
CLP information -5 keywords to see the development trend of the financial industry in 2022
6-3 读文章(*)
Leetcode force deduction question
Service学习笔记03- 前台服务实战
【线上问题】Timeout waiting for connection from pool 问题排查
Tidb unsafe recover (tikv downtime is greater than or equal to half the number of replicas)
6-1 需要多少单词可以组成一句话?
Connect the server with springboard / fortress through xshell