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 6994417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:53:23+00:00 2026-05-27T19:53:23+00:00

I have a newbie question, I’ve never read files bigger than 4Mb with function

  • 0

I have a newbie question, I’ve never read files bigger than 4Mb with function like fopen, ReadFile(WINAPI). My question is What is the best way to read a big file like 400Mb load blocks of 512 bits into memory?

Thanks

  • 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-27T19:53:24+00:00Added an answer on May 27, 2026 at 7:53 pm

    First of all – at first instance – you may not want to read that small – a few kBytes is better when it comes from disk. In your case – a simple implementation could read 16k – and then cycle through those 32 times for your 512 bytes operations.

    In reality that is not so important -as the OS is clever and generally will second guess you – and read more anyway. So a naive implementation where you simply do a

    do 
    { 
      bResult = ReadFile(hFile, &inBuffer, nBytesToRead, &nBytesRead, NULL); 
      do-something-with-nBytesRead; 
    } while(!bResult &&  nBytesRead != 0); 
    if (nBytesRead) error..; 
    

    sort of thing is fine.

    If you know you are always going to have such (rather large) files, performance is important and there is other use of those files too – then consider ‘memory mapping’ the file – i.e. open it in such a way that the entire file appears in virtual memory. Have a look at http://msdn.microsoft.com/en-us/library/windows/desktop/aa366556(v=vs.85).aspx for that.

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

Sidebar

Related Questions

This is a newbie question: I have a pre-existing function that I would like
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
quick and very basic newbie question. If i have list of dictionaries looking like
I have a newbie question! I want to do something like this: puts Example.new([a,b,c])
I have a newbie android question: Why arent strings and other resources like colors
Newbie question i have following function: function isadult($description) { $bad=/*comma separated bad words*/; $bad=explode(,,$bad);
My newbie question of the day is.... I have a comment function on my
Really newbie question: I have a .csv file that I need to read. I've
I have a newbie question regarding when to release the elements of a NSArray.
I have a newbie WPF question. Imagine my user control has a namespace declaration

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.