943,661 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 892
  • C++ RSS
Mar 20th, 2009
0

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

Expand Post »
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
C++ Syntax (Toggle Plain Text)
  1. FILE *fptrSampleVideo = fopen(filename,"rb+");
  2.  
  3. if(fptrSampleVideo)
  4. {
  5.  
  6. fseek(fptrSampleVideo,0,SEEK_END);
  7.  
  8. uncompressedVideoSize = ftell(fptrSampleVideo);
  9.  
  10. }
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
Reputation Points: 10
Solved Threads: 0
Light Poster
asifjavaid is offline Offline
40 posts
since Oct 2006
Mar 20th, 2009
0

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

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,949 posts
since Aug 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: array size declaration after inputs
Next Thread in C++ Forum Timeline: Problem grabbing the lowest value in C++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC