Alright after the program makes a folder I would liek to put a file in that folder but I want the file to be of a name the user would put in so how would I do that because as I have it set up now all it does is makes a file by he name of Exampleuser input and putting "/two" just makes a file by the name of two.
#include <iostream>
#include <direct.h>
#include <string>
#include <fstream>
using namespace std;
string newFolder = "Example";
string test ;
string two;
int main()
{
_mkdir((newFolder.c_str()));
getline(cin,test);
two = test;
fstream inout;
inout.open(newFolder + two,ios::out);
inout << " This is a test";
inout.close();
return 0;
}
The older standards of c++ require you pass a const char*
parameter to the std::fstream::open()
method. You can just write
inout.open(std::string(newFolder + "/" + two).c_str(),ios::out);
or for windows file system
inout.open(std::string(newFolder + "\\" + two).c_str(),ios::out);