my fstream always fails
<p>Please help, I have the following little snip code to test fsteam, but it always fails, and my strace file following after the code. 
It works in unix but not in linux. 
Thanks for your help.</p>

<hr>

<pre><code>#include &lt;fstream.h&gt;
#include &lt;iostream.h&gt;

using namespace std;

int main () {

        fstream filestr;

        filestr.open ("test.txt",ios::out | ios::in | ios::app );
        if(filestr.bad()) 
        {        
                cout &lt;&lt; "Bad input." &lt;&lt; endl; 
        }        
        if(filestr.fail()) 
        {        
                cout &lt;&lt; "Open failed." &lt;&lt; endl; 
        }       
        filestr &lt;&lt; " dsgesvsvds";

        filestr.close();

        return 0;
}
</code></pre>

<hr>

<pre><code>execve("./a.out", ["./a.out"], [/* 83 vars */]) = 0
brk(0)                                  = 0x10754000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b8cf1e9d000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b8cf1e9e000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("tls/x86_64/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/libstdc++.so.6", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("x86_64/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("libstdc++.so.6", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("/products/oracle/11.2.0/client/lib/tls/x86_64/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/products/oracle/11.2.0/client/lib/tls/x86_64", 0x7fffd262c040) = -1 ENOENT (No such file or directory)
open("/products/oracle/11.2.0/client/lib/tls/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/products/oracle/11.2.0/client/lib/tls", 0x7fffd262c040) = -1 ENOENT (No such file or directory)
open("/products/oracle/11.2.0/client/lib/x86_64/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/products/oracle/11.2.0/client/lib/x86_64", 0x7fffd262c040) = -1 ENOENT (No such file or directory)
open("/products/oracle/11.2.0/client/lib/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/products/oracle/11.2.0/client/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/roscodev/rosco/bin/tls/x86_64/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/roscodev/rosco/bin/tls/x86_64", 0x7fffd262c040) = -1 ENOENT (No such file or directory)
open("/roscodev/rosco/bin/tls/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/roscodev/rosco/bin/tls", 0x7fffd262c040) = -1 ENOENT (No such file or directory)
open("/roscodev/rosco/bin/x86_64/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/roscodev/rosco/bin/x86_64", 0x7fffd262c040) = -1 ENOENT (No such file or directory)
open("/roscodev/rosco/bin/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/roscodev/rosco/bin", {st_mode=S_IFDIR|0775, st_size=12288, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=80518, ...}) = 0
mmap(NULL, 80518, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2b8cf1e9f000
close(3)                                = 0
open("/usr/lib64/libstdc++.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&gt;\0\1\0\0\0000\364\304\3528\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=976312, ...}) = 0
mmap(0x38eac00000, 3145600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x38eac00000
mprotect(0x38eace6000, 2093056, PROT_NONE) = 0
mmap(0x38eaee5000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe5000) = 0x38eaee5000
mmap(0x38eaeee000, 73600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x38eaeee000
close(3)                                = 0
open("tls/x86_64/libm.so.6", O_RDONLY)  = -1 ENOENT (No such file or directory)
open("tls/libm.so.6", O_RDONLY)         = -1 ENOENT (No such file or directory)
open("x86_64/libm.so.6", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("libm.so.6", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/products/oracle/11.2.0/client/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/roscodev/rosco/bin/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libm.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&gt;\0\1\0\0\0`&gt;\200\3438\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=615136, ...}) = 0
mmap(0x38e3800000, 2629848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x38e3800000
mprotect(0x38e3882000, 2093056, PROT_NONE) = 0
mmap(0x38e3a81000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x81000) = 0x38e3a81000
close(3)                                = 0
open("tls/x86_64/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/libgcc_s.so.1", O_RDONLY)     = -1 ENOENT (No such file or directory)
open("x86_64/libgcc_s.so.1", O_RDONLY)  = -1 ENOENT (No such file or directory)
open("libgcc_s.so.1", O_RDONLY)         = -1 ENOENT (No such file or directory)
open("/products/oracle/11.2.0/client/lib/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/roscodev/rosco/bin/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libgcc_s.so.1", O_RDONLY)  = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&gt;\0\1\0\0\0P\36\200\3468\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=58400, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b8cf1eb3000
mmap(0x38e6800000, 2151784, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x38e6800000
mprotect(0x38e680d000, 2097152, PROT_NONE) = 0
mmap(0x38e6a0d000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd000) = 0x38e6a0d000
close(3)                                = 0
open("tls/x86_64/libc.so.6", O_RDONLY)  = -1 ENOENT (No such file or directory)
open("tls/libc.so.6", O_RDONLY)         = -1 ENOENT (No such file or directory)
open("x86_64/libc.so.6", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("libc.so.6", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/products/oracle/11.2.0/client/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/roscodev/rosco/bin/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0&gt;\0\1\0\0\0\220\332\1\3438\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1722304, ...}) = 0
mmap(0x38e3000000, 3502424, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x38e3000000
mprotect(0x38e314e000, 2097152, PROT_NONE) = 0
mmap(0x38e334e000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14e000) = 0x38e334e000
mmap(0x38e3353000, 16728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x38e3353000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b8cf1eb4000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b8cf1eb5000
arch_prctl(ARCH_SET_FS, 0x2b8cf1eb4bf0) = 0
mprotect(0x38e334e000, 16384, PROT_READ) = 0
mprotect(0x38e3a81000, 4096, PROT_READ) = 0
mprotect(0x38eaee5000, 24576, PROT_READ) = 0
mprotect(0x38e2e1b000, 4096, PROT_READ) = 0
munmap(0x2b8cf1e9f000, 80518)           = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b8cf1e9f000
write(1, "Open failed.\n", 13Open failed.
)          = 13
exit_group(0)                           = ?
</code></pre>

<hr>
