文件读写相关函数

来源:互联网 发布:c语言乘法函数是什么 编辑:程序博客网 时间:2024/06/01 10:45

#include <fcntl.h>

int creat(const char* path, mode_t mode);

int open(const char* path, int oflag, ...);

int openat(inf fd, const char* path, int oflag, ...);


#include <unistd.h>

int close (int fd);

off_t lseek(int fd; off_t offset, int whence);

whence 参数

SEEK_SET 文件偏移量设置为距文件开始offset个字节.

SEEK_CUR 文件偏移量设置为距离当前文职offset个字节(可正可负).

SEEK_END 文件偏移量设置为距离文件结尾offset个字节(可正可负).


ssize_t read(int fd, void* buf, size_t nbytes);

ssize_t write(int fd, void* buf, size_t nbytes);

原创粉丝点击