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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:32:24+00:00 2026-06-10T22:32:24+00:00

I have a data file that stored like this : 6 byte (3*16-bits) header.

  • 0

I have a data file that stored like this :

6 byte (3*16-bits) header.
– byte 0+1 (16-bits): x dimension
– byte 2+3 (16-bits): y dimension
– byte 4+5 (16-bits): z dimension
then: 3D volume data in x,y,z order. 16 bits (2 bytes) per voxel, only 12 bits of these 16 are used.

I want to load the data and store it in an array using C++

so how can I load 2 Bytes from a .data file the algorithm that I want to implement is

load(String filename)
{
 File fp = openfile(filename);
 Byte2 sizeX, sizeY, sizeZ;
 sizeX = readfile(sizeof(Byte2),fp);
 sizeY = readfile(sizeof(Byte2),fp);
 sizeZ = readfile(sizeof(Byte2),fp);
 UnsignedShort data[sizeX*sizeY*sizeZ];
 for(Integer z=0; z < sizeZ; z++) {
    for(Integer y=0; y < sizeY; y++) {
       for(Integer x=0; x < sizeX; x++) {
        data[x+y*sizeX+z*sizeX*sizeY] = readfile(sizeof(Byte2),fp);
      }
    }
  }
}
  • 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-06-10T22:32:26+00:00Added an answer on June 10, 2026 at 10:32 pm

    I would recommend using an ifstream object to read the data file. When you open a file in C++, you can mention that you want to read the data in binary instead of text. There is no direct equivalent of Java’s BinaryReader in C++.

    More details on ifstream can be found in this C++ reference page.

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

Sidebar

Related Questions

I have data stored in a csv file that looks like this: Date,BLOCK,,Wood,Miscellaneous,,Totals,MO Saturday,4055-RU,4055-AR,4091,1139,1158,,100
I have a data file that looks like this: xyz123 2.000 -0.3974 0.0 hij123
I have an XML file with data stored like this: <myxml> <item name=column18>88744544</item> <item
I have a data file that looks like the following example. I've added '%'
I have data that looks like this: token eps rank # first line names
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
I have a file that can store up to 8 bytes of data. I
I have to read/write an XML file that stores its data as bit masked
I have made a java application that stores data from a .csv file to
Say I have a data file that I want to process; I want to

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.