PDA

Click to See Complete Forum and Search --> : Testing to see if a file exists


Capablanca
Jul 12th, 2000, 11:59 PM
How can I test to see if a fil exists or is empty using the fstream.h library?

Thanks.

Wulf
Jul 25th, 2000, 10:25 AM
fstream(file_name,ios::in|ios::nocreate,NULL);
if( is_open() ){
close();

do opened stuff
}
else{
do closed stuff
}

Thats an existance test, an empty test probably requires other functions. I like using fopen/fread/fwrite/fclose