首頁  >  文章  >  後端開發  >  使用C/C++程式建立目錄或資料夾

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

PHPz
PHPz轉載
2023-08-28 23:17:061569瀏覽

使用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

以上是使用C/C++程式建立目錄或資料夾的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除