Creating folder in directory using CPP

I wanted to open a folder from the C++ program. This is so easy!! 😀
Just need the include the stdlib header file and a system command mkdir. Then to mention the drive to open the folder.

Here, I am giving the code segment for help. Enjoy!

#include <stdlib.h>

int main(){
system("mkdir d:\\folder");
return 0;

if you run the above code in CPP compiler, you will find a new folder named “folder” in the D drive of your computer.

One more thing! are you allergic or thinking why “return 0” at last or why “int main” in place of “void main”? Relax! it doesn’t make any difference for this program.. Just a fashion you could tell 😀

Thanks to daniweb for the help

another additional fun is, if you use the following code, you will see the program to be terminated but the specific folder in any drive will be opened.. very simple and kinda funny! this code is the bonus for you 😀

#include <stdlib.h>

int main(){
system("explorer C:\\php");
return 0;


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s