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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:40:42+00:00 2026-05-27T02:40:42+00:00

I cannot use strstr, memchr because array can contains any number of \0 chars,

  • 0

I cannot use strstr, memchr because array can contains any number of \0 chars, is there are any efficient ways to do that? I have to find all positions (indexes) or pointers.

  • 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-27T02:40:43+00:00Added an answer on May 27, 2026 at 2:40 am

    Piece of cake in C++:

    #include <string>
    
    const std::string needle = get_byte_sequence();
    const std::string haystack = get_data();
    
    
    std::size_t pos = haystack.find(needle);
    
    // found if pos != std::string::npos
    

    Another option is to use a generic algorithm:

    #include <algorithm>
    
    std::string::const_iterator it = std::search(data.begin(), data.end(), needle.begin(), needle.end());
    
    if (it != data.end())
    {
      // needle found at position std::distance(data.begin(), it);
    }
    else
    {
      // needle not found
    }
    

    Bear in mind that C++ string objects can contain arbitrary data. To create a string from a byte buffer, pass its size to the constructor:

    char buf[200];   // fill with your data; possibly full of zeros!
    
    std::string s(buf, 200); // no problem
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anything but Assetic (which I cannot use because of PHP version) that
I cannot use threads thus I want to write a server program that can
Why cannot use body::selection , when i want anything that can highlight to be
I am aware you cannot use an initialiser list for an array. However I
Is it true that you cannot use COM Interop to expose COM properties? Everything
Can someone explain to me why I cannot use document.getElementById('id').value inside of a function?
We're trying to use Axis2 to call a web service that cannot use HTTP/1.1
I am wondering why I cannot use variable column name like that: declare @a
i cannot use any bean value in my custom control.: for instance: this is
My symptom is that I cannot use a proxy with HTTPS requests with LWP.

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.