Using TFile

Hello All,
I am a little confused about using TFile in the same way one writes this statement in C:

if ((CONFIG=fopen("config","r"))==NULL) {....}

I want to read a root file, but it it does not exist I want to exit gracefully.
Right now it crashes with this error:

How do I check for the existence of the file and if it exist I want to open it just like I can do with :

if ((CONFIG=fopen("config","r"))==NULL) {....}

Thanks a lot.

use TFile:Open
TFile *file = TFile::Open(“myfile.root”);
if (!file) /file open failed
see also TFile::Recover

Rene

Thanks Rene for the message. I tried that but I am missing something.
I am reading the names of the root files to open from a text configuration file.

char ROOTfilename[256]; ... result=fscanf(CONFIG,"%i %s",&No_of_events,ROOTfilename); TFile *file = Tfile::Open(ROOTfilename);

gives an error.

Error: Function Open(ROOTfilename) is not defined in current scope makelistmode.C:39:[/i]

It must be TFile::Open and not Tfile::Open

Rene