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

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2006
Posts: 38
Reputation: asifjavaid is an unknown quantity at this point 
Solved Threads: 0
asifjavaid asifjavaid is offline Offline
Light Poster

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

 
0
  #1
Mar 20th, 2009
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
  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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,485
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #2
Mar 20th, 2009
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC