当前位置:网站首页>C language file reading and writing
C language file reading and writing
2022-07-03 08:50:00 【Cap07】
#define _CRT_SECURE_NO_WARNINGS
#include <malloc.h>
#include <stdlib.h>
#include <cstdio> //FILE The header file
int main() {
FILE* fp; // Define a point FILE Pointer variable of type structure
char ch;
if ((fp = fopen("D:/Cap/test.txt", "w")) == NULL) // Open the specified file in write only mode , The file address should use /, Otherwise it will be wrong
{
printf("cannot open file\n");
exit(0);
}
ch = getchar(); //fgetc Function brings back a character and assigns it to ch
while (ch != '#') // When the input "#" End cycle at
{
fputc(ch, fp); // Write the read characters to the disk file
ch = getchar(); //fgetc Function continues to bring back a character assigned to ch
}
fclose(fp); // Close file
return 0;
}边栏推荐
- PHP uses foreach to get a value in a two-dimensional associative array (with instances)
- Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation
- How to use Jupiter notebook
- 【Rust 笔记】11-实用特型
- 单调栈-42. 接雨水
- [concurrent programming] synchronization container, concurrent container, blocking queue, double ended queue and work secret
- Binary tree traversal (first order traversal. Output results according to first order, middle order, and last order)
- Dealing with duplicate data in Excel with xlwings
- [rust notes] 11 practical features
- php public private protected
猜你喜欢

UE4 source code reading_ Bone model and animation system_ Animation compression

JS ternary operator - learning notes (with cases)

Unity editor expansion - scrolling list

Visual Studio (VS) shortcut keys

基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
![[RPC] RPC remote procedure call](/img/dc/872204ea47fcff04cdb72e18a2a4ef.jpg)
[RPC] RPC remote procedure call

Animation_ IK overview

22-06-28 Xi'an redis (02) persistence mechanism, entry, transaction control, master-slave replication mechanism

二进制转十进制,十进制转二进制

Graphics_ Games101/202 learning notes
随机推荐
Annotations simplify configuration and loading at startup
Constraintlayout's constraintset dynamically modifies constraints
Final review of Database Principles
Unity learning notes
Es8 async and await learning notes
Apache startup failed phpstudy Apache startup failed
Unity Editor Extension - Outline
[rust notes] 08 enumeration and mode
22-06-27 Xian redis (01) commands for installing five common data types: redis and redis
How to delete CSDN after sending a wrong blog? How to operate quickly
Unity editor expansion - the framework and context of unity imgui
Binary to decimal, decimal to binary
【Rust 笔记】12-闭包
求组合数 AcWing 886. 求组合数 II
Message queue for interprocess communication
Monotonic stack -42 Connect rainwater
【Rust 笔记】08-枚举与模式
First Servlet
LinkedList set
Cesium for unreal quick start - simple scenario configuration