int main()
{
int fd;
fd = open("./file2",O_RDWR);
if(fd == -1)
{
printf("file2 no exist\n");
}
fd = open("./file2",O_RDWR|O_CREAT,0600);
if(fd > 0)
{
printf("file2 okok\n");
}
return 0;
}
linux 文件编程
int main()
{
int fd;
char *buf = "lll is ok";
fd = open("./file2",O_RDWR);
if(fd == -1)
{
printf("file2 no exist\n");
}
fd = open("./file2",O_RDWR|O_CREAT,0600);
if(fd > 0)
{
printf("file2 okok\n");
}
write(fd,buf,strlen(buf));
close(fd);
return 0;
}