Create Directory or Folder with C/C++ Program Last Updated : 30 Nov, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report Problem: Write a C/C++ program to create a folder in a specific directory path. This task can be accomplished by using the mkdir() function. Directories are created with this function. (There is also a shell command mkdir which does the same thing). The mkdir() function creates a new, empty directory with name filename. // mkdir() function int mkdir (char *filename) Note: A return value of 0 indicates successful completion, and -1 indicates failure. Program to create a directory in Windows using Turbo C compiler:Â CPP // C program to create a folder #include <conio.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> void main() { int check; char* dirname = "geeksforgeeks"; clrscr(); check = mkdir(dirname,0777); // check if directory is created or not if (!check) printf("Directory created\n"); else { printf("Unable to create directory\n"); exit(1); } getch(); system("dir"); getch(); } Output:Directory created. a.out geeksforgeeks main.c Program to create a directory in Linux/Unix using GCC/G++ compiler:Â CPP // C++ program to create a directory in Linux #include <bits/stdc++.h> #include <iostream> #include <sys/stat.h> #include <sys/types.h> using namespace std; int main() { // Creating a directory if (mkdir("geeksforgeeks", 0777) == -1) cerr << "Error : " << strerror(errno) << endl; else cout << "Directory created"; } Output:Directory created. Note: Above source codes would not run on online IDEs as the program requires the directory path in the system itself. Comment More infoAdvertise with us Next Article C++ Program to Create a File K kartik Improve Article Tags : C Programs C++ Programs Linux-Unix Similar Reads C++ Program to Create a File Problem Statement:Write a C++ program to create a file using file handling and check whether the file is created successfully or not. If a file is created successfully then it should print "File Created Successfully" otherwise should print some error message. Approach:Declare a stream class file and 2 min read C++ Program to Get the List of Files in a Directory Getting the list of files in a directory is one of the most common operations performed by the Filesystem of an OS. The file explorer application in most operating systems performs the same operation in the background. In this article, you will learn how to get the list of files in a directory using 4 min read How to Get Current Directory in C++ The current working directory, also known as the present working directory, is the location on the file system where the executing program is located and operates from. When working with files and directories in C++, it is important to determine the current working directory to find the resource fil 2 min read How to Check a File or Directory Exists in C++? Checking the presence of a directory or a file is one of the most common operations performed by a file system in an Operating System. Most programming languages offer some level of file system accessibility in form of library functions. In this article, you will learn how to test a file or director 4 min read C++ Program to Create a Temporary File Here, we will see how to create a temporary file using a C++ program. Temporary file in C++ can be created using the tmpfile() method defined in the <cstdio> header file. The temporary file created has a unique auto-generated filename. The file created is opened in binary mode and has access m 2 min read How to Write a Command Line Program in C? In C, we can provide arguments to a program while running it from the command line interface. These arguments are called command-line arguments. In this article, we will learn how to write a command line program in C. How to Write a Command Line Program in C? Command line arguments are passed to the 2 min read Like