当前位置:网站首页>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;
}
边栏推荐
- [concurrent programming] concurrent security
- Alibaba canal actual combat
- UE4 source code reading_ Bone model and animation system_ Animation process
- 【Rust 笔记】07-结构体
- Mortgage Calculator
- MySQL index types B-tree and hash
- 高斯消元 AcWing 883. 高斯消元解线性方程组
- [concurrent programming] Table hopping and blocking queue
- Get the link behind? Parameter value after question mark
- [concurrent programming] concurrent tool class of thread
猜你喜欢
Concurrent programming (VI) ABA problems and solutions under CAS
JS ternary operator - learning notes (with cases)
Markdown learning
ES6 promise learning notes
Message queue for interprocess communication
单调栈-84. 柱状图中最大的矩形
Alibaba canaladmin deployment and canal cluster Ha Construction
Constraintlayout's constraintset dynamically modifies constraints
UE4 source code reading_ Mobile synchronization
Slice and index of array with data type
随机推荐
[concurrent programming] thread foundation and sharing between threads
22-06-27 Xian redis (01) commands for installing five common data types: redis and redis
Unity interactive water ripple post-treatment
分配异常的servlet
[concurrent programming] synchronization container, concurrent container, blocking queue, double ended queue and work secret
22-05-26 西安 面试题(01)准备
php public private protected
cres
Unity editor expansion - controls, layouts
[concurrent programming] atomic operation CAS
How to delete CSDN after sending a wrong blog? How to operate quickly
Really explain the five data structures of redis
On the setting of global variable position in C language
[concurrent programming] working mechanism and type of thread pool
Servlet的生命周期
[rust notes] 06 package and module
First Servlet
[concurrent programming] collaboration between threads
Life cycle of Servlet
OpenGL learning notes