954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ftell() is returning the wrong position of file why?

Hi,

I have a file of approximately 4.19GB. I want to get the totall size of file using code in VC++, Here is my code

FILE *fptrSampleVideo = fopen(filename,"rb+");

if(fptrSampleVideo)
{

fseek(fptrSampleVideo,0,SEEK_END);

uncompressedVideoSize = ftell(fptrSampleVideo);

}

If the file is of small size, ftell() return position correctly and the size is also correct.

If the file is of large size (4.19GB), ftell() return position 4, which is wrong.

It must return 4,190,000,000 etc. some thing like that.

can any one guide me what is the case?

Many Thanks,

--
Regards,
Asif

asifjavaid
Light Poster
40 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

ftell() returns a long int, and the max value is declared in limits.h. If yours is like mine then the 4 gigs is too big.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You