open.c

来源:互联网 发布:ccx中线持仓指标源码 编辑:程序博客网 时间:2024/06/16 23:12

/*open.c*/
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int fd;
if((fd = open("/tmp/hello.c", O_CREAT | O_TRUNC | O_WRONLY , 0600 ))<0){
perror("open:");
exit(1);
}
else{
printf("Open file: hello.c %d/n",fd);
}
if( close(fd) < 0 ){
perror("close:");
exit(1);
}
else
printf("Close hello.c/n");
exit(0);
}

原创粉丝点击