当前位置:网站首页>C language fcntl function
C language fcntl function
2022-07-03 14:40:00 【ma_ de_ hao_ mei_ le】
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
int fd = open("a.txt", O_RDWR);
char buf[12138] = {
0};
// Writing again at this time is additional writing
read(fd, buf, 12138);
printf(" Original content :%s\n", buf);
// Get the original flag And plus O_APPEND flag
int flag = fcntl(fd, F_GETFL) | O_APPEND;
// Set up flag
fcntl(fd, F_SETFL, flag);
char* str = "\tafter append";
// Writing again at this time is additional writing
write(fd, str, strlen(str));
close(fd);
fd = open("a.txt", O_RDWR);
read(fd, buf, 12138);
printf(" Additional content :%s\n", buf);
return 0;
}

边栏推荐
- 7-16 find the set of integers that meet the given conditions
- Statistical capital consonants
- Write a 2-minute countdown.
- 7-28 monkeys choose King (Joseph problem)
- 基因家族特征分析 - 染色体定位分析
- Find specified characters
- String sort
- Tonybot humanoid robot starts for the first time 0630
- MySQL multi table query subquery
- 洛谷P3065 [USACO12DEC]First! G 题解
猜你喜欢
![洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解](/img/89/da1a3a38e02671628f385de0f30369.png)
洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解

Analysis of gene family characteristics - chromosome location analysis

【北大青鸟昌平校区】互联网行业中,哪些岗位越老越吃香?

pyQt界面制作(登录+跳转页面)

Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules

US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars

Understand the application scenario and implementation mechanism of differential segment

On MEM series functions of C language

Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块

Code writing and playing method of tonybot humanoid robot at fixed distance
随机推荐
Recent learning summary
Thread.sleep和TimeUnit.SECONDS.sleep的区别
Dllexport and dllimport
Analysis of gene family characteristics - chromosome location analysis
7-9 one way in, two ways out (25 points)
Rasterization: a practical implementation (2)
分布式事务(Seata) 四大模式详解
ZABBIX saves the page blank after adding calculated items
Selective sorting
FPGA blocking assignment and non blocking assignment
Zzuli:1040 sum of sequence 1
Luogu p5536 [xr-3] core city solution
洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解
7-3 rental (20 points)
556. 下一个更大元素 III : 简单构造模拟题
Zzuli:1046 product of odd numbers
7-19 check denomination (solve binary linear equation)
一文了解微分段应用场景与实现机制
Detailed explanation of four modes of distributed transaction (Seata)
Timecho of Tianmou technology completed an angel round financing of nearly 100 million yuan to create a native timing database of the industrial Internet of things