现在的位置: 首页 > 综合 > 正文

linux open file

2018年05月14日 ⁄ 综合 ⁄ 共 304字 ⁄ 字号 评论关闭
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>


int main(int argc, char *argv[]){
  int fd;

  if((fd=open("example.c", O_CREAT|O_EXCL, S_IRUSR|S_IWUSR))==-1){
    perror("open");
    exit(1);
  }else{
    printf("create file success\n");
  }

  close(fd);
  return 0;
}

抱歉!评论已关闭.