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

  • Home
  • SEARCH
  • 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 3695034
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:34:07+00:00 2026-05-19T04:34:07+00:00

I have a binary data which I am reading into an array of long

  • 0

I have a binary data which I am reading into an array of long integers using a C programme.

A hexdump of the binary data shows that after first few data points, it starts again at a location 20000 hex addresses away.
hexdump output is as shown below.

0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0020000 0000 0000 0053 0000 0064 0000 006b 0000
0020010 0066 0000 0068 0000 0066 0000 005d 0000
0020020 0087 0000 0059 0000 0062 0000 0066 0000

… and so on…
But when I read it into an array ‘data’ of long integers by the typical fread command

fread(data,sizeof(*data),filelength/sizeof(*data),fd);

It is filling up with all zeros in my data array till it reaches the 20000 location. After that it reads in data correctly.
Why is it reading regions where my file is not there? Or how will I make it read only my file, not anything in between which are not in file?

I know it looks like a trivial problem, but I cannot figure it out even after Googling one night.
Can anyone suggest me where I am doing it wrong?

Other Info: I am working on a GNU/Linux machine. (slax-atma distro to be specific). My C compiler is gcc.

  • 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-19T04:34:08+00:00Added an answer on May 19, 2026 at 4:34 am

    The hex dump output shows that the first line (16 bytes) of data are all zeroes; the ‘*’ indicates that the following lines are the same, until you reach offset 0x0020000. So, the start of your file is all zeroes.

    The read call reads the file as if the zeroes were present on disk because the Unix/Linux interface is defined to do that. Whether they are stored on disk or not is immaterial; as far as your program is concerned, they are there.

    If you want to skip the ‘all zero’ part of the file, then preferably don’t write the file with all zeroes at the start. Failing that, you’ll have to decide how to read the data in chunks until you start finding non-zero information – or use a fixed offset to jump over the zeroes.

    So, the file system abstraction on Unix and Linux means that the zeroes are read, whether they are physically stored on disk or not. To skip them, you have to know how you want to do that – either by knowing how many there are and seeking past them, or by reading and discarding data.

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

Sidebar

Related Questions

I have a big lump of binary data in a char[] array which I
I have binary data in a file that I can read into a byte
I have an function which decodes the encoded base64 data in binary data but
I have a simulation that reads large binary data files that we create (10s
I have a binary file that I have to parse and I'm using Python.
I have two files (f1 and f2) containing some text (or binary data). How
Alright. So I have a very large amount of binary data (let's say, 10GB)
I have always been interested in algorithms, sort, crypto, binary trees, data compression, memory
If you have binary strings (literally String objects that contain only 1's and 0's),
I have a binary file - Windows static library (*.lib). Is there a simple

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.