博客
关于我
Linux打开及创建文件
阅读量:742 次
发布时间:2019-03-21

本文共 429 字,大约阅读时间需要 1 分钟。

#include 
#include
#include
#include
int main() { int fd; fd = open("./demo1file", O_RDWR | O_CREAT, 0600); printf("%d\n", fd); return 0;}

这段代码演示了如何使用文件操作。在程序中,我们首先包括了一些系统相关的文件,例如sys/types.hsys/stat.hfcntl.hstdio.h。然后,我们使用open()函数打开文件./demo1file,使用 bitte的权限组合O_RDWRO_CREAT,以及文件权限0600。如果文件不存在,则会创建一个新的文件。程序随后打印文件描述符fd,最后返回0。

这段代码可以在任意支持C语言的开发环境中运行,用于处理文件操作。

转载地址:http://lwagz.baihongyu.com/

你可能感兴趣的文章
Python url请求提示certificate verify failed unable to get local issuer certificate
查看>>
Python UTC 日期时间对象的 ISO 格式不包括 Z(祖鲁语或零偏移)
查看>>
python valueerror object2_python遇到错误记录
查看>>
python vars的作用
查看>>
Python vcrpy库:HTTP请求记录和重放
查看>>
Python virtualenv
查看>>
python vue3实现大文件分段续传(断点续传)--带暂停和继续功能
查看>>
Python WebDriver如何打印整个页面源(html)
查看>>
Python WebSocket自动化测试:构建高效接口测试框架
查看>>
Python Web开发
查看>>
Redis 配置文件杂项。
查看>>
Python web自动化测试 —— 文件上传
查看>>
Python web自动化测试 —— 文件上传!
查看>>
Python Web自动化测试开发环境搭建(附安装包与虚拟机环境)
查看>>
python win32api键盘_Python win32api.keybd_event模拟键盘输入
查看>>
python Windows显示当前鼠标坐标
查看>>
python Workbook 表格宽度
查看>>
python write报错a byte-like object is required.not str
查看>>
PYTHON调用大模型实现图片生成
查看>>
python yaml.dump 缩进错误
查看>>