Click to See Complete Forum and Search --> : C++


wlj
August 21st, 1999, 03:20 PM
How do you test to see if a file is empty
(Zero length) ??? I am not using Visual C++ & MFC.
Please send source code example.

Thanks in advance.

Wlj

replika
August 21st, 1999, 09:12 PM
This is how it could be done:


#include <iostream.h>
#include <sys\types.h>
#include <sys\stat.h>

bool some_func()
{
struct stat finfo;

if(stat("SOMEFILE.DAT", &finfo) != 0)
{
cerr << "Unable to obatin file information.";
return false;
}

cout << "Size of file: " << finfo.st_size << endl;

return true;
}