下面这段程序,是一段调用Linux API读写的程序
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(void)
{
int fd = open("./dict.txt",O_RDONLY);
printf("fd=%d\n",fd);
close(fd);
printf("close ok...\n");
return 0;
}
下面是含创建的程序
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(void)
{
int fd = open("./dict.cp",O_RDONLY| O_CREAT, 0644);
printf("fd=%d\n",fd);
close(fd);
printf("close ok...\n");
return 0;
}
下面是open函数详细参数介绍