当前位置:网站首页>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;
}
边栏推荐
- Escape from heaven and forget what he suffered. In ancient times, it was called the punishment of escape from heaven. Article collection
- Markdown learning
- Dom4j traverses and updates XML
- Monotonic stack -42 Connect rainwater
- [RPC] RPC remote procedure call
- Convert video to GIF
- Slice and index of array with data type
- 【Rust笔记】06-包和模块
- Graphics_ Learnopongl learning notes
- Intersectionpicker in osgearth
猜你喜欢
How to place the parameters of the controller in the view after encountering the input textarea tag in the TP framework
Animation_ IK overview
Concurrent programming (III) detailed explanation of synchronized keyword
Constraintlayout's constraintset dynamically modifies constraints
Graphics_ Games101/202 learning notes
【Rust笔记】02-所有权
Query XML documents with XPath
Vscode, idea, VIM development tool shortcut keys
JS ternary operator - learning notes (with cases)
22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制
随机推荐
Unity editor expansion - the design idea of imgui
Concurrent programming (III) detailed explanation of synchronized keyword
[concurrent programming] explicit lock and AQS
Dom4j遍历和更新XML
Deep parsing JVM memory model
Binary to decimal, decimal to binary
Final review of Database Principles
Talking about: is the HashSet set ordered or disordered /hashset set unique, why can we store elements with the same content
Cesium for unreal quick start - simple scenario configuration
[rust notes] 13 iterator (Part 1)
OpenGL learning notes
单调栈-503. 下一个更大元素 II
[concurrent programming] collaboration between threads
[concurrent programming] thread foundation and sharing between threads
如何应对数仓资源不足导致的核心任务延迟
UE4 source code reading_ Bone model and animation system_ Animation compression
Alibaba canal actual combat
[RPC] RPC remote procedure call
UE4 source code reading_ Bone model and animation system_ Animation node
The method for win10 system to enter the control panel is as follows: