The simple answer is no. More precisely, it's system dependent: under
Unix, it's possible (e.g. using stat
); under Windows, it's not
possible for a text file, but if you're reading the file in binary,
there's a function GetFileSize
which can be used.
Although not guaranteed, under all of the implementations I know (for
these two platforms), seeking to the end of the file, then doing an
ftell
, will return something which, when converted to a sufficiently
large integral type, will give the same results as the above (with the
same restrictions).
Finally: why do you need this information? If it's just to allocate an
appropriately sized buffer, even with a text file, GetFileSize
(and
tell
after seeking to the end) will return a value slightly larger
than the number of bytes you can read. You're buffer will be slightly
oversized, but this is generally not a problem.