页次: 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
离线
页次: 1