Create Directory or Folder with C/C++ Program

 Problem: Create a folder in a given directory path using a C/C++
program.

The create_directory() function, defined in filesystem header,  can be
used to perform this purpose. This function is used to create directories.The
create_directory() function creates a new, empty directory named after the
name specified as a parameter.

// create_directory() function
bool create_directory(director_name);

note that a true return boolean value denotes success, whereas a false return value indicates failure.

program to make a directory in c++ | IDE : Visual studio 2019 

#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;

int main()
{
	// c++ 17 standard
	bool status = fs::create_directory("newFolder");
	if (status) {
		std::cout << "folder is created" << std::endl;
	}
	else {
		std::cout << "failed! cannot make a folder" << std::endl;
	}
}
learn more 
Share this Post

Leave a Reply

Your email address will not be published. Required fields are marked *