bool returns false, chdir() still works...
Jan 24, 2011 at 3:54am UTC
ok so i have a function
1 2 3 4 5
bool fexists(const char *filename)
{
std::fstream ifile(filename);
return ifile;
}
which simply returns whether or not the file or path exists. But when i use it in this for loop,
1 2 3 4 5 6 7 8 9 10 11
for (int n =0;n < i-1;n++)
{
startchar = directory_path.find('\\' ,startchar);
endchar = directory_path.find('\\' ,startchar+1);
totalchar = endchar - startchar;
string path = directory_path.substr(startchar+1,totalchar);
startchar = endchar;
cout << path << "\n" ;
if (fexists(path.c_str()) == false ){cout << "folder does not exist" ;}
chdir(path.c_str());
}
where directory_path does entirely exist. The first folder is said to exist, and everything else is said not to exist. But chdir still works... so what exactly is happening here?
Jan 24, 2011 at 5:40am UTC
Figured out, not posting code unless asked.
Basically I wrote another function to read the entire contents of the current directory and then searched it for the string given.
Topic archived. No new replies allowed.