How to create a directory and create a file in a particular directory in c++?
In c++
Collapse
X
-
You have two different questions.
How to make a directory in C++? C++ doesn't have that capability. You'll have to find a subroutine supplied by your operating system. In Linux, you use mkdir. In windows, I don't know.
How to make a file in a directory in C++? C++ can do this. You specify the path and directory name and pass that complete name to the ofstream object. The default open options of ofstream will create a file for you if it doesn't exist.
Ofstream will not create a directory for you. You need to make sure the directory is created before creating the file.
Comment