This is really strange. Absolute path doesn't work for both ifstream and ostream. It works when I use a relative path like so:
ofstream out;
out.open("file2.txt");
string river = "i love cheese";
if(!out){
cout << "error"; // have breakpoint set here
} else {
out << river; // have breakpoint set here (stops here when debugging)
}
out.close();
But when I use an absolute path, it doesn't. I am well aware of needing to use "\" for the slash and I've tried using "/" instead and it still doesn't work.
ofstream out;
out.open("C:\\file2.txt"); // also tried "C:/file2.txt"
string river = "i love cheese";
if(!out){
cout << "error"; // have breakpoint set here (stops here when debugging)
} else {
out << river; // have breakpoint set here
}
out.close();
I really need it to work with an absolute path since that is what is provided to the function and the input and output files won't always be in the same folder as the binary.