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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:05:32+00:00 2026-05-26T18:05:32+00:00

I have one binary file which I have created. In it, data is stored

  • 0

I have one binary file which I have created. In it, data is stored in binary form but I will show it in human readable form like ;

[someOtherData]opalgo$apollo$[someOtherData]
               ^
               ^
               ^
             file pointer

I want hold that data “opalgo” in temp_S, which is declared as string.To note, not shown at example, I don’t know what data is this place and its length.

To take data reside in binary file ;

  • First, I have calculated its length by incrementing file pointer and each time, I did comparison with ‘$’.
  • Second, I come back by length of data, for this case |opalgo| = 6.
  • Third, each time, I take one char and concatenate it with string, which is initialized with “” . that is, string += temp_Char ;

Above algorithm is mess, of course in my opinion. I couldn’t find efficient way to take data from binary file. Now, I am a bit ashamed. Can you give me a better way ?

EDIT: I don’t know file size, but as you know, I can calculate by using seekg and tellg.

  • 1 1 Answer
  • 3 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-26T18:05:32+00:00Added an answer on May 26, 2026 at 6:05 pm

    Instead of doing it in three steps, it could all be done in the first: While looking for ther terminating ‘$’ just put the characters into temp_S. No need to calculate length.

    std::ifstream input(...);
    
    std::string temp_S;
    char c;
    while (input.get(c))
    {
        if (c == '$')
            break;  // Found terminator, read no more into string
        temp_S += c;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one binary file which I have created. In it, data is stored
i have one file (name.dat) which is binary data, it has 12 lines of
I have a binary file which is simple a list of signed 32 bit
I have to concatenate 3 binary files into one, but I am getting an
I have some binary data which contains a bunch of functions and want to
I think it is quite normal to have more than one binary in a
I have a class that I need to binary serialize. The class contains one
I have one std::list<> container and these threads: One writer thread which adds elements
I have one application which uses the standard .NET forms authentication cookie, now I
i want to read\write a binary file which has the following structure: The file

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.