Can I make C++ make a folder using the I/O method?. Also in the code "ofstream a_file" is "a_file" a C++ command, like could I call it "sdjs_file" if I wanted?
Can I make C++ make a folder using the I/O method?. Also in the code "ofstream a_file" is "a_file" a C++ command, like could I call it "sdjs_file" if I wanted?
a_file is just the name of he ofstream object. You can call it whatever you want (assuming it fits in the rules for variable names and it isn't already in use or a reserved word. "ofstream a_file" just creates an object called a_file that is of type ofstream, and then you can use that object to work with files in a purely output capacity.
I've never seen a folder made using File I/O, but I don't know if can or not. My guess is that it's OS dependant, and you'll probably have to use the system function (cstdlib / stdlib.h) to do it. system() is often advised against for a variety of reasons, but under the circumstances I don't think it's a huge problem here.
>Can I make C++ make a folder using the I/O method?
You can make one using the function mkdir(). I don't think it's standard, but most compilers have it.
Code:#include <dir.h> #include <iostream> int main() { if (mkdir("\\dir\\subdir") != 0) { std::cout << "Could not make dir." << std::endl; return 1; } std::cout << "Directory created." << std::endl; }