当前位置:网站首页>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;
}边栏推荐
- Dom4j traverses and updates XML
- 22-05-26 Xi'an interview question (01) preparation
- 【Rust笔记】06-包和模块
- Unity learning notes
- 【Rust笔记】05-错误处理
- C language student management system based on linked list, super detailed
- Unity editor expansion - scrolling list
- Facial expression recognition based on pytorch convolution -- graduation project
- Dealing with duplicate data in Excel with xlwings
- PHP uses foreach to get a value in a two-dimensional associative array (with instances)
猜你喜欢

How to place the parameters of the controller in the view after encountering the input textarea tag in the TP framework

22-06-27 Xian redis (01) commands for installing five common data types: redis and redis

第一个Servlet

Monotonic stack -503 Next bigger Element II

22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制

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

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

Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation

高斯消元 AcWing 883. 高斯消元解线性方程组

请求参数的发送和接收
随机推荐
Binary tree traversal (first order traversal. Output results according to first order, middle order, and last order)
How to delete CSDN after sending a wrong blog? How to operate quickly
Unity multi open script
Graphics_ Games101/202 learning notes
[rust note] 10 operator overloading
UE4 source code reading_ Bone model and animation system_ Animation process
JS non Boolean operation - learning notes
[rust notes] 11 practical features
22-06-27 Xian redis (01) commands for installing five common data types: redis and redis
UE4 source code reading_ Mobile synchronization
SQL statement error of common bug caused by Excel cell content that is not paid attention to for a long time
PHP uses foreach to get a value in a two-dimensional associative array (with instances)
First Servlet
Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation
【Rust 笔记】10-操作符重载
How to place the parameters of the controller in the view after encountering the input textarea tag in the TP framework
第一个Servlet
Notes and bugs generated during the use of h:i:s and y-m-d
Common DOS commands
Unity editor expansion - controls, layouts