一、源码
/*p4.4.cxx :using mkdir to create a directory*/
#include /*for exit()*/
#include
#include
#include /*for perror()*/
int main(void)
{
char* pathname="/tmp/a";
/*mode 设置为0700, 开始的0表示八进制*/
if(mkdir(pathname, 0700) == -1)
{
perror("Couldn't create the directory");
exit(1);
}
exit(0);
}
二、编译
[root@gateway c_study]# gcc p4.4.c -o p4.4
三、运行
[root@gateway c_study]# ./p4.4
四、验证
[root@gateway c_study]# ll /tmp/
总用量 16
drwx------ 2 root root 4096 8月 31 14:51 a