当前位置:网站首页>6-3 读文章(*)
6-3 读文章(*)
2022-06-11 17:17:00 【西红柿_码农】
请编写函数,从文件中读出文章,将其输出到屏幕上。
函数原型
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;
}
/* 你提交的代码将被嵌在这里 */打开 Windows 的记事本软件,复制下面的文字内容,保存文件并命名为“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!"
输入样例
(无)
输出样例
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);
}
}边栏推荐
- 6-7 文件读写操作
- Arraylist集合、对象数组
- Go get downloaded package path
- 端口规划与APJ
- ffmpeg奇偶场帧Interlace progressive命令和代码处理
- How to become an optimist organization?
- 闭包的简单理解
- Semaphore PV operation of process interaction and its code implementation
- Authing 双周动态:应用市场上线(5 .10 —5 .22 )
- Use exe4j to convert The jar file is packaged as Exe file
猜你喜欢

Authoring share | understanding saml2 protocol

Environment configuration and pymysql installation

端口规划与APJ

Authing 双周动态:Authing 论坛上线(4.25-5.8)

Recyclerview cache reuse analysis, source code interpretation

ffmpeg CBR精准码流控制三个步骤

ShellBrowser . NET Crack

Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?

Derivation of child numbering formula for nodes numbered I in full k-ary tree

The use of histogram function in MATLAB
随机推荐
TypeScipt基础
Real time myth -- real-time RTOS multitask performance analysis
What problems are exposed when all Sohu employees are cheated?
用实际案例分析PMP与ACP应该考哪个?哪个更有用?
Format eslint automatique lorsque vscode enregistre le Code
Guide to Dama data management knowledge system: percentage of chapter scores
定制 or 订阅?未来中国 SaaS 行业发展趋势是什么?
Global and China Mobile Network Optimization (MnO) industry development panoramic survey and Investment Strategy Research Report 2022-2028
通过Xshell连接有跳板机/堡垒机的服务器
LeetCode-384. Scramble array
Authoring share | understanding saml2 protocol
Bentley 使用 Authing 快速实现应用系统与身份的集成
Association relationship
Axi protocol Basics
QLineEdit 设置输入掩码
What is the minimum change price of PTA futures? How can PTA futures be safe?
Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?
Centos7 server configuration (IV) -- installing redis
信息安全数学基础 Chapter 1——整除
6-6 批量求和(*)