Home > Backend Development > C++ > Create a directory or folder using a C/C++ program

Create a directory or folder using a C/C++ program

PHPz
Release: 2023-08-28 23:17:06
forward
1667 people have browsed it

Create a directory or folder using a C/C++ program

In this tutorial, we will discuss a program to create a directory or folder using a C/C program.

To create a new directory, we will use the mkdir() command. Please note that the given code only works with the Windows compiler.

Example

#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();
}
Copy after login

Output

Directory created
Copy after login

The above is the detailed content of Create a directory or folder using a C/C++ program. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template