首页 > 文章列表 > 使用C/C++程序创建目录或文件夹

使用C/C++程序创建目录或文件夹

使用C/C编程创建目录 使用C/C编程创建文件夹 C/C目录/文件夹创建
318 2023-09-02

在本教程中,我们将讨论使用 C/C++ 程序创建目录或文件夹的程序。

要创建新目录,我们将使用 mkdir() 命令。请注意,给定的代码仅适用于 Windows 编译器。

示例

#include <conio.h>
#include <dir.h>
#include <process.h>
#include <stdio.h>
void main(){
   int check;
   char* dirname = "tutorialspoint";
   clrscr();
   check = mkdir(dirname);
   //checking if directory is created
   if (!check)
      printf("Directory createdn");
   else {
      printf("Unable to create directoryn");
      exit(1);
   }
   getch();
   system("dir/p");
   getch();
}

输出

Directory created