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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:34:48+00:00 2026-05-23T08:34:48+00:00

I would like to delete parts from a binary file, using C++. The binary

  • 0

I would like to delete parts from a binary file, using C++. The binary file is about about 5-10 MB.

What I would like to do:

  1. Search for a ANSI string “something”
  2. Once I found this string, I would like to delete the following n bytes, for example the following 1 MB of data. I would like to delete those character, not to fill them with NULL, thus make the file smaller.
  3. I would like to save the modified file into a new binary file, what is the same as the original file, except for the missing n bytes what I have deleted.

Can you give me some advice / best practices how to do this the most efficiently? Should I load the file into memory first?

How can I search efficiently for an ANSI string? I mean possibly I have to skip a few megabytes of data before I find that string. >> I have been told I should ask it in an other question, so its here:
How to look for an ANSI string in a binary file?

How can I delete n bytes and write it out to a new file efficiently?

OK, I don’t need it to be super efficient, the file will not be bigger than 10 MB and its OK if it runs for a few seconds.

  • 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-23T08:34:48+00:00Added an answer on May 23, 2026 at 8:34 am

    There are a number of fast string search routines that perform much better than testing each and every character. For example, when trying to find “something”, only every 9th character needs to be tested.

    Here’s an example I wrote for an earlier question: code review: finding </body> tag reverse search on a non-null terminated char str

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

Sidebar

Related Questions

I would like to remove/delete a migration file. How would I go about doing
I would like to know the best way to delete records from a live
I would like to test a string containing a path to a file for
i have a weird problem. i would like to delete an assembly(plugin.dll on harddisk)
I have two tables A and B. I would like to delete all the
in my code i would like boost::shared_ptr not to call delete but call ptr->deleteMe()
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I would like to sort an array in ascending order using C/C++ . The
I would like to have a reference for the pros and cons of using
I may have found a Subversion bug, and I would like to make sure

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.