Sep 2, 2015 at 4:52pm UTC
#include<fstream.h>
#include<conio.h>
#include<direct.h>
void main()
{
clrscr();
mkdir("H:\\Documents\\MyFolder");
ofstream ofile("H:\\Documents\\Myfile.txt");
getch();
}
Neither the mkdir command is working, nor the ofstream statement. If I write
mkdir("H:\\MyFolder");
ofstream ofile("H:\\Myfile.txt");
it works
but
mkdir("H:\\Documents\\MyFolder");
ofstream ofile("H:\\Documents\\Myfile.txt");
Does not work....The Folder Document is already created.. Why??
Last edited on Sep 2, 2015 at 7:01pm UTC
Sep 2, 2015 at 5:56pm UTC
I have seen this question in another thread.
Before making a directory you should check if it exist already.
And the file , is supposed to be/opened in that directory ? Because it does not look at this path.