当前位置:网站首页>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;
}边栏推荐
- Binary tree sorting (C language, char type)
- Collection interface
- 22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制
- [redis] redis persistent RDB vs AOF (source code)
- [rust notes] 13 iterator (Part 1)
- Unity notes 1
- 如何应对数仓资源不足导致的核心任务延迟
- Unity editor expansion - draw lines
- Osganimation library parsing
- [concurrent programming] consistency hash
猜你喜欢
![[concurrent programming] Table hopping and blocking queue](/img/b7/023991a00956e469af855e7a81e126.jpg)
[concurrent programming] Table hopping and blocking queue

Binary to decimal, decimal to binary

On the setting of global variable position in C language

Thymeleaf 404 reports an error: there was unexpected error (type=not found, status=404)

Vscode, idea, VIM development tool shortcut keys

Try to reprint an article about CSDN reprint

单调栈-503. 下一个更大元素 II

Deep parsing (picture and text) JVM garbage collector (II)

Collection interface

UE4 source code reading_ Bone model and animation system_ Animation node
随机推荐
Alibaba canal actual combat
【Rust 笔记】12-闭包
[redis] redis persistent RDB vs AOF (source code)
Query XML documents with XPath
file_ put_ contents
TP5 order multi condition sort
Unity Editor Extension - Outline
[public key cryptography] ECC elliptic cryptosystem (implementing ElGamal encryption method)
【Rust 笔记】09-特型与泛型
too many open files解决方案
Facial expression recognition based on pytorch convolution -- graduation project
[concurrent programming] explicit lock and AQS
MySQL three logs
[rust notes] 08 enumeration and mode
22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制
Thymeleaf 404 reports an error: there was unexpected error (type=not found, status=404)
单调栈-84. 柱状图中最大的矩形
ES6 promise learning notes
Common DOS commands
Graphics_ Learnopongl learning notes