当前位置:网站首页>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;
}
边栏推荐
- Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
- Programming language: the essence of type system
- tonybot 人形机器人 查看端口并对应端口 0701
- 7-3 rental (20 points)
- 7-15 calculation of PI
- 洛谷P5536 【XR-3】核心城市 题解
- 数学常数表 by q779
- Common commands for getting started with mongodb database
- 分布式事务(Seata) 四大模式详解
- Tonybot humanoid robot checks the port and corresponds to port 0701
猜你喜欢
ConstraintLayout 的使用
一文了解微分段应用场景与实现机制
puzzle(016.4)多米诺效应
tonybot 人形机器人 定距移动 代码编写玩法
Tonybot Humanoïde Robot Infrared Remote play 0630
Programming language: the essence of type system
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
Rasterization: a practical implementation (2)
Understand the application scenario and implementation mechanism of differential segment
Code writing and playing method of tonybot humanoid robot at fixed distance
随机推荐
Preliminary summary of structure
适用于XP的DDK
Dllexport and dllimport
7-9 one way in, two ways out (25 points)
Zzuli:1049 square sum and cubic sum
How to query the baby category of tmall on Taobao
Luogu p4047 [jsoi2010] tribal division solution
Doris学习笔记之数据表的创建
Talking about part of data storage in C language
基因家族特征分析 - 染色体定位分析
Plane vector addition
7-20 print 99 formula table (format output)
C language to implement a password manager (under update)
ShowMeBug入驻腾讯会议,开启专业级技术面试时代
To improve efficiency or increase costs, how should developers understand pair programming?
Time conversion ()
7-24 reduction of the simplest fraction (rolling Division)
分布式事务(Seata) 四大模式详解
Rasterization: a practical implementation (2)
一文了解微分段应用场景与实现机制