Check to see if file is empty
Author |
Message |
cyberguy
|
Posted: Mon Jan 04, 2010 7:38 pm Post subject: Check to see if file is empty |
|
|
Is there any if statement to check if a file is empty? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DemonWasp
|
Posted: Mon Jan 04, 2010 7:57 pm Post subject: 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
|
Posted: Mon Jan 04, 2010 8:00 pm Post subject: 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. |
|
|
|
|
 |
|
|