
-----------------------------------
cyberguy
Mon Jan 04, 2010 7:38 pm

Check to see if file is empty
-----------------------------------
Is there any if statement to check if a file is empty?

-----------------------------------
DemonWasp
Mon Jan 04, 2010 7:57 pm

RE:Check to see if file is empty
-----------------------------------
You can probably just check the file's size or length against 0. If it's 0, the file is empty, otherwise not. I don't know how you'd find the length of a file in C++ offhand though.

-----------------------------------
TheGuardian001
Mon Jan 04, 2010 8:00 pm

Re: Check to see if file is empty
-----------------------------------
I believe you can do this using istream::peek(), which returns the value of the next character in a file, but leaves it as the next character to be read.

open a file, peek(), and if it returns EOF, your file is empty.
