Getting the file size...

F

f0r3nsic

How do I get a file's size in C? I'm only using the standard C library,
nothing else.
 
J

John Harrison

f0r3nsic said:
How do I get a file's size in C? I'm only using the standard C library,
nothing else.

Perhaps you should ask on comp.lang.c then?

The usually answer is to open the file (fopen), seek to the end of the
file (fseek), then get your current position (ftell) then close the file
(fclose).

john
 
J

jvyyuie

How do I get a file's size in C? I'm only using the standard C library,
nothing else.

FILE* fp;
fp=fopen("...", "r+b");
if(fp==NULL)
return false;

fseek(fp, 0L, SEED_END);
long length=ftell(fp);
rewind(fp);

....

fclose(fp);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,779
Messages
2,569,606
Members
45,239
Latest member
Alex Young

Latest Threads

Top