You are here:

C/File Handling

Advertisement


Question

Sir,
I have used filelength function in C as follows,

long l;
l=filelength(fileno(fp))

The result is not correct for files having length greater than integer's max size (in bytes).

What to do .  

Answer
For that, you will have to write your own function filelength_long().
And finding a file size is not a big thing.
Open the file. Goto the end of the file and do ftell() and you will get the size.
Or you can use stat/lstat/fstat functions to get the size.  

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.