linux open

一直记住不打开文件时候的mode,今天发现原来可以直接用0644这样的八进制数字代替,好开森

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(){
    umask(0);
    int fd = open ("111",O_WRONLY | O_CREAT , 0644);
    if(fd == -1){
        perror("open file error");
    }
    return 0;
}

ok

原文地址:https://www.cnblogs.com/cdwodm/p/5029414.html