Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7077089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:22:46+00:00 2026-05-28T06:22:46+00:00

I need to access a file larger than 2gb using C. During one run

  • 0

I need to access a file larger than 2gb using C. During one run of the program a variable number of bytes will be read from the file and the location of the next position saved. During the next run of the program the file position is read and a number of bytes are read starting from that location.

The complication is that occasionally the file may be ‘compressed’ by copying it to a new file, less any bytes that have already been read (I think copying is the only way to do that). The number of bytes removed in this way will also be saved.

I need to know the current position of the file from the original start for synchronizing with another file. This should be easy because it is just (current_offset + deleted_bytes).

The reason it is not easy is the fseek only uses long int indexes which limits the file to 2gb, and fsetpos uses an fpos_t structure for the position index, which is not a number and can’t be converted back and forth to one. I don’t know of any way to use a long long int index for file positioning, which would be the ideal solution.

What do I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:22:47+00:00Added an answer on May 28, 2026 at 6:22 am

    On windows you can use _lseeki64() to do 64 bit seeks.

    For compatibility with linux, you can also add -D_FILE_OFFSET_BITS=64 at compile time, and then do this in one of your headers:

    #ifdef __MINGW32__ // or whatever you use to find out you're compiling on windows
    #define lseek _lseeki64
    #endif
    

    then use lseek() everywhere as usual. This works because windows ignores the _FILE_OFFSET_BITS flag, and linux won’t see the redefinition of lseek.

    There’s also _fseeki64() if you prefer a FILE* version, and there are equivalent 64 bit tell() and ftell() functions too (_telli64() and _ftelli64()).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two different modules that need access to a single file (One will
I need to access the struts.action.extension value in the struts.xml file from an interceptor.
I need to store some simple properties in a file and access them from
i need to import a mysql file into my access db. how do i
I need to create an ANSI text file from an Access recordset that outputs
I need to store a file, such that my ASP.Net MVC app can access
I have a file as documentRoot/app/webroot/myFile.php I need to be able to access this
There are some text files(Records) which i need to access using C#.Net. But the
Background: I have one Access database (.mdb) file, with half a dozen tables in
My program needs to read chunks from a huge binary file with random access.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.