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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:53:49+00:00 2026-06-10T01:53:49+00:00

Hi everyone i have an issue while reading binary data from a binary file

  • 0

Hi everyone i have an issue while reading binary data from a binary file as following:

File Content:
D3 EE EE 00 00 01 D7 C4 D9 40

char * afpContentBlock = new char[10];
ifstream inputStream(sInputFile, ios::in|ios::binary);

if (inputStream.is_open()))
{
    inputStream.read(afpContentBlock, 10);

    int n = sizeof(afpContentBlock)/sizeof(afpContentBlock[0]); // Print 4

    // Here i would like to check every byte, but no matter how i convert the 
    // char[] afpContentBlock, it always cut at first byte 0x00.
}

I know this happens cause of the byte 0x00. Is there a way to manage it somehow ?
I have tried to write it with an ofstream object, and it works fine since it writes out the whole 10 bytes. Anyway i would like to loop through the whole byte array to check bytes value.

Thank you very much.

  • 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-10T01:53:51+00:00Added an answer on June 10, 2026 at 1:53 am

    It’s much easier to just get how many bytes you read from the ifstream like so:

    if (inputStream.is_open()))
    {
       inputStream.read(afpContentBlock, 10);
       int bytesRead = (int)inputStream.gcount();
    
       for( int i = 0; i < bytesRead; i++ )
       {
          // check each byte however you want
          // access with afpContentBlock[i]
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone, I have written a script that downloads a zip file from a
Everyone. I have a little issue with selecting value from the dropdown list. When
Have a weird issue. I am upgrading from 5.6.2 and following the documented suggested
everyone. I have some labels that I draw them in the xib file, and
H everyone, I have the following: $html = '<ul class=pagination-all>'; $html .= '<li class=pagination-start><div
Hello everyone, I have some confusion regarding some Win32 API data types and macros
every one..i have one issue while runing phonegap facebook plugin.i have Downloaded phonegap facebook
Good Afternoon, everyone. I have an ongoing issue with the code below. I know
Hello everyone I have a problem. I want to do a GridView with a
Have a nice day everyone, I have something to ask your hel, to better

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.