I am not sure what else to try in order to address this issue.
And here is the output from the program:
As far as I can tell, all permissions are set correctly and there is no reason that I can see why both the fstream and the ifstream objects fail. By the way, I am running on a linux system with gcc version 4.1.2 20080704 (Red Hat 4.1.2-48).
-Marco
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char *argv[])
{
fstream mfile("./ftest.txt", fstream::in | fstream::out);
std::cout << "fstream fail: " << (mfile.fail() == 1 ? "true" : "false") << std::endl;
mfile.close();
ifstream ifile("./itest.txt");
std::cout << "ifstream fail: " << (ifile.fail() == 1 ? "true" : "false") << std::endl;
ifile.close();
ofstream ofile("./otest.txt");
std::cout << "ofstream fail: " << (ofile.fail() == 1 ? "true" : "false") << std::endl;
ofile << "1, 2, 3, test, test\n";
ofile.close();
return(0);
}
Code:
[mquezada@otw14 ~/fstreamTest]$ g++ -o fstreamTest fstreamTest.cpp [mquezada@otw14 ~/fstreamTest]$ ./fstreamTest fstream fail: true ifstream fail: true ofstream fail: false [mquezada@otw14 ~/fstreamTest]$ ls -la total 52 drwxrwxrwx 2 mquezada users 4096 Nov 22 11:15 . drwxr-xr-x 88 mquezada users 20480 Nov 22 10:39 .. -rwxr-xr-x 1 mquezada users 9484 Nov 22 11:15 fstreamTest -rw-r--r-- 1 mquezada users 605 Nov 22 10:51 fstreamTest.cpp -rw-r--r-- 1 mquezada users 12288 Nov 22 10:52 .fstreamTest.cpp.swp -rw-r--r-- 1 mquezada users 20 Nov 22 11:15 otest.txt [mquezada@otw14 ~/fstreamTest]$ more otest.txt 1, 2, 3, test, test [mquezada@otw14 ~/fstreamTest]$
-Marco
Comment