当前位置:网站首页>6-2 writing articles (*)
6-2 writing articles (*)
2022-06-11 17:37:00 【Tomatoes_ Menon】
6-2 Write an article (*)
fraction 10
Full screen browsing topics
Switch layout
author Li Xiang
Company Hubei Institute of Economics
Please write a function , Enter an article from the keyboard , Write it to a file .
The function prototype
void WriteArticle(FILE *f);explain : Parameters f For file pointer . Function to enter an article from the keyboard ( Composed of several lines of text , With Ctrl+Z end ), Write it to f In the indicated file .
judging procedures
#include <stdio.h>
#include <stdlib.h>
void WriteArticle(FILE *f);
int main()
{
FILE *f;
f = fopen("Article.txt", "w");
if (!f)
{
puts(" The file could not be opened !");
exit(1);
}
WriteArticle(f);
if (fclose(f))
{
puts(" File cannot be closed !");
exit(1);
}
puts(" File saved successfully !");
return 0;
}
sample input
Poor Old Gentleman
An old gentleman was walking slowly along a street one day when he saw a little
boy who was trying to reach a doorbell which was too high for him. He was a
kind-hearted old man, so he stopped and said, "I will ring the bell for you,"
and then he pulled the bell so hard that it could be heard all over the house.
The little boy looked up at him and said, "Now we will run away. Come on." And
before the old gentleman knew what was happening, the naughty boy had run round
the corner of the street, leaving the man to explain to the angry owner of the
house why he had rung the bell.
Tips : Press enter after the last line is entered , Press at the beginning of the next line Ctrl + Z ( The screen shows ^Z), Then press the Enter key to end the input .
sample output
File saved successfully !
open “Article.txt” file , View file contents .
Article.txt
Poor Old Gentleman
An old gentleman was walking slowly along a street one day when he saw a little
boy who was trying to reach a doorbell which was too high for him. He was a
kind-hearted old man, so he stopped and said, "I will ring the bell for you,"
and then he pulled the bell so hard that it could be heard all over the house.
The little boy looked up at him and said, "Now we will run away. Come on." And
before the old gentleman knew what was happening, the naughty boy had run round
the corner of the street, leaving the man to explain to the angry owner of the
house why he had rung the bell.void WriteArticle(FILE *f){
char data;
data=getchar();
while(data!=EOF){
fputc(data,f);
data=getchar();
}
}
边栏推荐
- 删除链表的倒数第N个节点---2022/02/22
- 开源项目那么多,这次带你了解个版本的区别,明白alpha版、beta版、rc版是什么意思
- Tidb CDC create task error unknown or incorrect time zone
- 6-1 需要多少单词可以组成一句话?
- 【线上问题】Timeout waiting for connection from pool 问题排查
- Read and understand the development plan for software and information technology service industry during the "14th five year plan"
- Custom or subscription? What is the future development trend of China's SaaS industry?
- 聚类方法汇总
- 论文阅读 dyngraph2vec: Capturing Network Dynamics using Dynamic Graph Representation Learning
- Tidb CDC synchronization of features not available in MySQL to MySQL
猜你喜欢

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

Threejs uses indexeddb cache to load GLB model

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

Leetcode力扣刷题

05_ Feature Engineering - dimension reduction

Valid parentheses ---2022/02/23

vscode配置eslint自动格式化报错“Auto Fix is enabled by default. Use the single string form“

which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_ mod

ffmpeg硬编解码 Inter QSV

Merge K ascending linked lists ---2022/02/26
随机推荐
What subclasses inherit, polymorphism, and upward transformation
tidb-cdc日志tables are not eligible to replicate
Authing biweekly news: online application market (5.10-5.22)
Service学习笔记01-启动方式与生命周期
开源项目那么多,这次带你了解个版本的区别,明白alpha版、beta版、rc版是什么意思
Authing 双周动态:Authing 论坛上线(4.25-5.8)
使用exe4j 将.jar文件打包为.exe文件
搜狐全员遭诈骗,暴露哪些问题?
spawn ./ gradlew EACCES at Process. ChildProcess._ handle. onexit
6-1 需要多少单词可以组成一句话?
Speed adjustment of tidb DDL
vscode保存代码时自动eslint格式化
删除链表的倒数第N个节点---2022/02/22
Authoring share | understanding saml2 protocol
Chapter II relational database
定制 or 订阅?未来中国 SaaS 行业发展趋势是什么?
6-2 多个整数的逆序输出-递归
拜登下令强制推行零信任架构
Set object mapping + scene 6-face mapping + create space in threejs
Xie Yang, CEO of authing, was selected into Forbes' 30 under 30 Asia list in 2021