Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

man page: https://man7.org/linux/man-pages/man2/open.2.html

const char* file = "test_file.txt";
int pfd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0777);

O_WRONLY:只写
O_CREAT:如果不存在则创建
O_APPEND:追加写
0777:所有组给全部权限

int pfd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0777);

O_TRUNC:覆盖写

评论