Please include the question in the body of your post.
"how can i find the size of a binary file"
<There is no reliable way to do this in portable standard C. You can
read through the file, adding up how many bytes you've read, but
that's both slow and not 100% reliable. An implementation is allowed
to treat a binary file as if it had some implementation-defined
number of null bytes append to it (C99 7.19.2p3), though I don't
know of any implementations that actually do that.
You can open the file (in binary mode), then fseek() to the end of
it, then use ftell() to get the current position. That's *usually*
going to be the size of the file, but it's still not 100% portable
for the reasons stated above. Furthermore, ftell() returns a long
int; if long int is 32 bits on your system, it's not going to work
for files that are 2 GiB or bigger.
Your operating system probably provides a way to get this information
directly. On Unix-like systems, stat() does this ("man 2 stat"
for details). On other systems, consult your documentation or ask
in a system-specific forum.
This happens to be one of those things that's much easier to do in
a system-specific way than by using portable C.
And watch out for race conditions. Whatever method you use will tell you
the size of the file at the moment when you did the query. The file can
grow, shrink, or even vanish between that and the time when try to do
something with the information.
--
Keith Thompson (The_Other_Keith)
ks...@mib.org <
http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"