#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <unistd.h>
// off_t lseek(int fd, off_t offset, int whence);
// ssize_t read(int fd, void *buf, size_t count);
int main()
{
int fd;
fd=open("./file1\n",O_RDWR|O_CREAT|O_EXCL,0600);
if(fd==-1){
printf("FILE EXIST\n");
}
return 0;
}
~
O_CREAT 用法 文件不存在则创建他
O_EXCL 判断文件是否存在
O_APPEND 每次写文件都到文件尾端
O_TRUNC 把文件原来的内容干掉 ,重新写