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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:53:29+00:00 2026-05-30T00:53:29+00:00

I am writing a C++ program to read an exe file. I wrote it

  • 0

I am writing a C++ program to read an exe file. I wrote it and I test it on a text file instead of exe file. it was true.

when I test it with an exe file I understand that my exe file have 0x00 value in it (not at its end). so my while loop stop before end of file because I used:

class A{
private:
ifstream myFile;
void Read(char *filename)
};

void A::Read(char *str)
{
myFile.open(str,ios::binary);

    while (!myFile.eof())
    {
       InputFile.get(ch);
       myString.push_back(ch);
    }
}

what should I do? if I should use size of the file, how can i get it?

  • 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-30T00:53:31+00:00Added an answer on May 30, 2026 at 12:53 am

    Only a hunch here, but my suspicion is that you’re actually reading the whole file correctly, but measuring it wrong.

    File reading (with binary mode) won’t stop on a 0-byte, but there are several string related methods that will.

    For example, you can’t measure the size of a binary “blob” using strlen(), you can’t copy it using strcpy().

    Without seeing the actual way you’re storing and measuring the data, it’s hard to see where things go wrong, but I strongly suspect that you’re actually reading the whole file correctly if you’re using binary mode.

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

Sidebar

Related Questions

Im writing a program that should read input via stdin, so I have the
I'm writing a program for an exercise that will read data from a file
I have to write a program that read from a file that contains the
hi I have a program that log some data in text file in specific
I am writing a program to read files and search text in it. I
In a program that I'm writing, I wanted to make a ConfigParser that's read
I have written a program a.exe which launches another program I wrote, b.exe ,
I am writing a program that needs to read a set of records that
I'm writing a program that uses the textbox in visual C# to read a
I am writing a program to read lines of text from 5 files and

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.