
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Create Directory or Folder with C/C++ Program
In this tutorial, we will be discussing a program to create directory or folder with C/C++ program.
To create a new directory we will be using the mkdir() command. Note that the given code will work only for 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(); }
Output
Directory created
- Related Articles
- How to create a directory in project folder using Java?
- C# Program to check whether a directory exists or not
- How to create a Directory using C#?
- C# Program to Estimate the Size of Folder
- C# Program to check if a path is a directory or a file
- Get Operating System temporary directory / folder in Java
- How to create a folder if it does not exist in C#?
- How can I create directory tree using C++ in Linux?
- C# Program to Delete Empty and Nonempty Directory
- C# program to create a ValueType with names
- Java Program to delete file or directory
- C# Program to get the name of root directory
- C# Program to display the name of the directory
- C# Program to split parts in a Windows directory
- Java Program to rename a file or directory

Advertisements