当前位置:网站首页>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);
}
}边栏推荐
- 论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
- 定制 or 订阅?未来中国 SaaS 行业发展趋势是什么?
- threejs中设置物体的贴图+场景的6面贴图 +创建空间
- 聚类方法汇总
- Vscode configures eslint to automatically format with an error "the setting is deprecated. use editor.codeactionsonsave instead with a source“
- How to become an optimist organization?
- 6-2 多个整数的逆序输出-递归
- Authing 背后的计算哲学
- Arraylist集合、对象数组
- 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
猜你喜欢
![[MySQL] detailed explanation of redo log, undo log and binlog (4)](/img/67/6e646040c1b941c270b3efff74e94d.png)
[MySQL] detailed explanation of redo log, undo log and binlog (4)

Authing biweekly news: online application market (5.10-5.22)

Qlineedit set input mask

【线上问题】Timeout waiting for connection from pool 问题排查

sql server中关于FORCESCAN的使用以及注意项

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

聚类方法汇总

Semaphore PV operation of process interaction and its code implementation

The use of histogram function in MATLAB

Service学习笔记01-启动方式与生命周期
随机推荐
CLP information -5 keywords to see the development trend of the financial industry in 2022
搜狐全員遭詐騙,暴露哪些問題?
Use of forcescan in SQL server and precautions
Speed adjustment of tidb DDL
Test and analysis of tidb write hotspot
vscode保存代碼時自動eslint格式化
Chapter II relational database
Authing 双周动态:Authing 论坛上线(4.25-5.8)
Mathematical foundations of information security Chapter 3 - finite fields (II)
6-8 有结构文件的读写1
开源项目那么多,这次带你了解个版本的区别,明白alpha版、beta版、rc版是什么意思
String to numeric value
Port planning and APJ
tidb-cdc日志tables are not eligible to replicate
require和ES6 import的区别
tidb-数据误删恢复的几种方式
Arraylist集合、对象数组
spawn ./gradlew EACCES at Process.ChildProcess._handle.onexit
Semaphore PV operation of process interaction and its code implementation
6-2 写文章(*)