Sep 1, 2015 at 4:23pm 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");
ifstream ofile("H:\\Myfile.txt");
it works
but
mkdir("H:\\Documents\\MyFolder");
ifstream ofile("H:\\Documents\\Myfile.txt");
Does not work....The Folder Document is already created.. Why??
Last edited on Sep 1, 2015 at 4:51pm UTC
Sep 1, 2015 at 4:42pm UTC
Are you sure that there is folder named Documents and that you have write permission to it?
Sep 1, 2015 at 4:46pm UTC
Ye I am Sure
Please note that compiler used is Borland C++
Last edited on Sep 1, 2015 at 4:46pm UTC
Sep 1, 2015 at 5:03pm UTC
Maybe you can get a useful error message by printing strerror(errno)
.
Last edited on Sep 1, 2015 at 5:03pm UTC
Sep 2, 2015 at 7:02pm UTC
I mean the Documents folder is already created...
Sep 2, 2015 at 7:26pm UTC
I thought you where using ofstream but I notice you are using ifstream. Is that a mistake? If you want the program to create the file you probably want to use ofstream instead.
Last edited on Sep 2, 2015 at 7:27pm UTC