problem with fstream

Hey guys, hope some of you will help with this problem i have.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
    int ok=1,num=0,choice=1;
    char inff[30];
    string filen;

    do
    {
        cout<<"Enter the name of the file with an extension (.bin)\n";
        cin>>filen;
        fstream f;

        f.open(filen.c_str(),ios::out|ios::in|ios::binary);
		num=f.fail();


so the num becomes = 1
i checked the eof() it is 0
i checked bad() it is 0
so i think the failbit is set.

what type of problem could it be.

also when i pass this object to any function ( even after using clear() )
the fail bit again becomes 1

and the teelg() function returns -1
Maybe the file doesn't exist? .open will only create a file if input flag is not set (because input from a non existent file is silly).
yay that fixed my problem.
thx a lot man, i was debugging that program for 2 weeks
Topic archived. No new replies allowed.