Creating a folder with subfolders
So I have been using mkdir() to make my folders, only problem is that it doesn't create subfolders.
I.e. if mkdir("c:\a\b\c\d") but if c:\a\b\c are not present it doesn't make d folder.
To circumvent this i made this code, it looks fine and runs fine but crashes at the end. No idea why though :/ Might have missed something silly.
Thanks!
Code:
#include <iostream>
#include<fstream>
#include <direct.h>
using namespace std;
int main()
{
char file_loc[140] = "C:/a/b/c/d/";
char tempfile_loc[140] = {' '};
int counter = 0;
do
{
while( file_loc[counter] != '/' )
{
tempfile_loc[counter] = file_loc[counter];
counter++;
}
tempfile_loc[counter] = file_loc[counter];
counter++;
cout << tempfile_loc << endl;
mkdir(tempfile_loc); // problem only makes one folder at a time
} while (file_loc[counter+1] != ' ' );
return 0;
}