Hey everybody,
I am trying to make a simple program that creates a directory, switches to it, creates another, switches to that, and then proceeds to make a file. I first thought of using a batch file, but input is messy (if not impossible). I have been trying to use system("cd directory");, but it doesn't change directories. Here is the code:
Code:
#include <fstream>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
char name[20];
char md[24] = "MD ";
char cd[24] = "CD ";
cin >> name;
strcat(md, name);
system(md);
strcat(cd, name);
system(cd);
system("MD Classes");
system("CD Classes");
strcat(name, ".uc");
ofstream createFile (name);
return 0;
}
When run, it creates the two directories and the .uc file in the program's directory (I want the .uc file inside of one directory, which is inside of the other directory). Can programs not change what directory the are operating in? Any help with a fix would be appreciated. Thanks.