网站开发技术

记点笔记、 学点技术 欢迎交流建站技术。本站关注lamp技术

您尚未登录。

#1 2015-01-27 13:52:45

admin
管理员

linux 系统文件函数总结

  1. open 函数 打开文件

       #include <sys/types.h>
       #include <sys/stat.h>
       #include <fcntl.h>

       int open(const char *pathname, int flags);
       int open(const char *pathname, int flags, mode_t mode);

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

2. 文件的创建 creat

       #include <sys/types.h>
       #include <sys/stat.h>
       #include <fcntl.h>

       int open(const char *pathname, int flags);
       int open(const char *pathname, int flags, mode_t mode);

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

3. 文件的关闭

       #include <unistd.h>

       int close(int fd);

4. 文件的读

       #include <unistd.h>

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

5. 文件的写

       #include <unistd.h>

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

6.文件指针的移动

       #include <sys/types.h>
       #include <unistd.h>

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

示例: 



ipbbs.net

离线

页脚

Powered by FluxBB