|
学习c编程遇到一个不明白的地方。请看下面一段程序
/* fdopen.c - Opening and Closing file descriptors */
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main(void)
{
int fd;
char path[] = "hello";
if((fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, color=red]0644 )) < 0){
perror("open");
exit(EXIT_FAILURE);
}
else{
printf("opened %s\n",path);
printf("descriptor is %d\n",fd);
}
if(close(fd) < 0){
perror("close");
exit(EXIT_FAILURE);
}
else{
printf("closed %s\n",path);
}
exit(EXIT_SUCCESS);
}
文件模式的掩码示应该是几位呢?我看书上为五位,尝试用00644,编译也正确,为什么呢? |
|