Ofstream writes empty file on linux
Posted
by commanderz
on Stack Overflow
See other posts from Stack Overflow
or by commanderz
Published on 2010-05-24T09:33:09Z
Indexed on
2010/05/24
9:41 UTC
Read the original article
Hit count: 216
Hi, I have a program which writes its output using ofstream. Everything works perfectly fine on Windows when compiled with Visual Studio, but it only writes empty file on Linux when compiled with GCC.
ofstream out(path_out_cstr, ofstream::out);
if(out.bad()){
cout << "Could not write the file" << flush;
}
else{
cout << "writing";
out << "Content" << endl;
if(out.fail()) cout << "writing failed";
out.flush();
out.close();
}
The directory which is being writen into has 0777 privileges.
Thanks for help
© Stack Overflow or respective owner