使用 C/C++ 程式建立目錄或資料夾


在本教程中,我們將討論使用 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 created\n");
   else {
      printf("Unable to create directory\n");
      exit(1);
   }
   getch();
   system("dir/p");
   getch();
}

輸出

Directory created

更新時間:2020 年 3 月 16 日

3K+ 瀏覽

開啟您的 職業生涯

透過完成課程獲得認證

開始入門
廣告