当前位置:网站首页>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);
}
}边栏推荐
- ffmpeg奇偶场帧Interlace progressive命令和代码处理
- Valid parentheses ---2022/02/23
- Chorus翻译
- tidb-ddl的速度的调整
- 【Mysql】redo log,undo log 和binlog详解(四)
- R language to find missing value location of data set
- Tidb unsafe recover (tikv downtime is greater than or equal to half the number of replicas)
- How does Sister Feng change to ice?
- Mathematical foundations of information security Chapter 3 - finite fields (II)
- 04_特征工程—特征选择
猜你喜欢

QLineEdit 设置输入掩码

04_特征工程—特征选择

Hands on deep learning - multiple input and output channels in the convolution layer

Automated testing selenium

Bentley 使用 Authing 快速实现应用系统与身份的集成

Service learning notes 01 start method and life cycle

Chorus翻译

Qlineedit set input mask

Authing biweekly news: authing forum launched (4.25-5.8)

From manufacturing to "intelligent manufacturing", explore the way for manufacturing enterprises to break the situation
随机推荐
Use of forcescan in SQL server and precautions
Set object mapping + scene 6-face mapping + create space in threejs
【线上问题】Timeout waiting for connection from pool 问题排查
信息安全数学基础 Chapter 3——有限域(一)
Is it safe for Xiaobai to open an account directly on the flush?
Xie Yang, CEO of authing, was selected into Forbes' 30 under 30 Asia list in 2021
关于元素位置和尺寸
av_read_frame返回值为-5 Input/output error
From manufacturing to "intelligent manufacturing", explore the way for manufacturing enterprises to break the situation
Typescipt Basics
Classification and method of feature fusion
Difference between require and ES6 import
TiDB-unsafe recover(tikv宕机数大于等于一半副本数)
Read and understand the development plan for software and information technology service industry during the "14th five year plan"
threejs利用indexeddb缓存加载glb模型
How to simplify a lot of if... Elif... Else code?
6-5 统计单词数量(文件)(*)
ADB command learning notes
通过Xshell连接有跳板机/堡垒机的服务器
6-2 多个整数的逆序输出-递归