Hi,can anyone tell me how to check if a file exists,I am using turbo c++ 3.0
Thank you for your time.

There may be some non-standard functions to do so in TC++, but I would just try to open it using an fstream object then use the .is_open() method to make sure that it has opened successfully. That's kind of quick and dirty, as I'm sure there are different OS dependent ways to do that, so someone should definitely correct me if I'm off base.

Okay I tried with .is_open(),but an error showed up

'is_open' is not a member of 'ofstream'
now what to do?

Well, you want to open it using ifstream, but since your compiler is pre-standard it may not have that method of the class (I seem to remember this from another poster at one point).

What will probably work (and is also used) is to test that the ifstream object is not null:

ifstream ifs("myfile.txt");
if(!ifs)
   //file didn't open for whatever reason
Comments
worked :)
This question has already been answered. Start a new discussion instead.