一、函数介绍

  mkdir()属于目录IO,目录IO就是对目录的读写操作

  int mkdir(const char *path,mode_t mode)

    功能:创建目录

    参数:第一个参数---目录名

       第二个参数---为该目录的访问权限 

    返回值:若目录创建成功则返回0,否则返回-1

二、代码示例

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>

int main(int argc, char *argv[])
{
    int ret = mkdir(argv[1], 0777);
        if(ret < 0 )
        {
             printf("creat dir failed!\n");
             return -1;
        }
 
    return 0;
}
     

 

相关文章:

  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-12-10
  • 2021-09-05
  • 2021-11-28
猜你喜欢
  • 2021-04-04
  • 2022-02-01
  • 2021-04-21
  • 2021-09-28
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案