#include <iostream>
#include <direct.h>
using namespace std;
int main() {
if( _mkdir("d:\\a\\b") == 0 ){
cout << "success";
} else if ( _mkdir("d:\\a") == EEXIST ) {
cout << "Directory was not created because dirname is the name of an existing file, directory, or device.";
}
else if ( _mkdir("d:\\a") == ENOENT ) {
cout << "Path was not found.";
}
}
On running the program the output is unexpected.(Most of the times it is a fail. I don’t know the reason)
sometimes i see success.Many times i if i remove double slash \\ with single slash \ the message is success .
This thing is making me furious. Why is this happening ?
Are backslashes the problem ?
UPDATE
in visual c++ 2010 express edition when i press CTRL+F5 the output is only press any key to continue…
The double slashes are correct. Check the error number to find out why it is failing:
Note that:
Likely causes:
aandbwith the same call (use e.g.SHCreateDirectoryEx()instead)