LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 774|回复: 0

文件模式的问题mode

[复制链接]
发表于 2004-11-26 22:56:27 | 显示全部楼层 |阅读模式
学习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,编译也正确,为什么呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表