要创建新目录,我们将使用 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++程序创建目录或文件夹的详细内容。
