Trong hướng dẫn này, chúng ta sẽ thảo luận về một chương trình tạo thư mục hoặc thư mục bằng chương trình C / C ++.
Để tạo một thư mục mới, chúng ta sẽ sử dụng lệnh mkdir (). Lưu ý rằng mã đã cho sẽ chỉ hoạt động đối với trình biên dịch windows.
Ví dụ
#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();
} Đầu ra
Directory created