zoukankan      html  css  js  c++  java
  • Linux C 文件与目录1 创建目录

    linux C    创建目录

    创建目录函数:mkdir 

     函数原型:int mkdir(char * pathname , mode_t mode);

    pathname字符指针是表示需要创建的目录路径,mode表示权限的八进制数字。创建成功返回整形数0,否则返回整数-1

      头文件:sys/types.h 和 sys/stat.h

    例子:

    [root@centos-64-min file]# cat mkdir.c
    #include<stdio.h>
    #include<sys/types.h>
    #include<sys/stat.h>
    #include<errno.h>
    int main(void)
    {
    extern int errno;
    char * path = "/root/mkdir1";

    if(mkdir(path , 0766)==0)
    {
    printf("created the directory %s . " , path);
    }
    else
    {
    printf("can't creat the directoty %s. , path");
    printf("errno:%d ",errno);
    printf("ERR : %s ",strerror(errno));
    }
    }
    [root@centos-64-min file]# ./mkdir
    created the directory /root/mkdir1 .

  • 相关阅读:
    多线程 介绍
    AE中如何获取曲线的一部分(转)
    friday
    THU
    MON
    SAT
    周三
    TUE
    绝对遗憾!
    monday
  • 原文地址:https://www.cnblogs.com/King-Penguin/p/5211552.html
Copyright © 2011-2022 走看看