0

I manage a PDF file whose size is 2.15GB, I opened the file with fopen, I use _fseeki64 and _ftelli64 in order to get or update the pointer position in the file and it works correctly.

I use fread in order to read from the pdf file. Usually it works properly, but when the read pointer is located near to the end of the file, fread get the EOF character which is wrong.

So, how can I read correctly from this large PDF file.

NB: I use the same source code with file whose size is less than 2GB and it works correctly.

Ajay
  • 18,086
  • 12
  • 59
  • 105
ZINEBA
  • 33
  • 1
  • 6

4 Answers4

2

Sounds to me that your're seeing the 2G limit of a signed 32-bit integer. The maximum value of such a variable is 2,147,483,647.

Edit

Use a debugger and check the actual value and type sent to _fseeki64and _ftelli64.

anorm
  • 2,255
  • 1
  • 19
  • 38
0

With a modern compiler (VS2012+ on Windows) you can use fstream which is the standard way to access large files.

See this answer for details.

Community
  • 1
  • 1
graham.reeds
  • 16,230
  • 17
  • 74
  • 137
0

Since you mentioned things like EOF, so please check if you are using fread properly. Most importantly the loop if its there in which you try to read data in chunks.

Please check if you are not a victim of Wrongly using loop while using fread

Community
  • 1
  • 1
sameerkn
  • 2,209
  • 1
  • 12
  • 13
0

There is no matter with the fread function, But, the read pointer of the file was already located at the end of the file. That's why it return EOF. When I change the read pointer position, fread works properly.

ZINEBA
  • 33
  • 1
  • 6
  • 1
    This information should be added to your question by editing it not posted as an *answer* - SO is not a discussion forum. – Clifford Jun 03 '16 at 08:31