0

today I am trying to find a pattern of bytes in an array (in this case pointer)

I do know I could use std::string needle() and haystack etc. but I was wondering if I could use that with BYTE (unsigned char)?

I also know the length of the BYTE *_zone so that's not an issue either. Any ways I could go forth to do this? (also any code examples are appreciated :))

Thanks again!

0

3 Answers 3

1

The find() method of std::string is a member function that is intended to find another std::string or a character array char* inside the std::string

So to answer your question if the haystack is a std::string you should be able to pass the char* arrays directly to the find methods.

If the haystack is not a std::string you can make a std::string out of it and then do the same.

Sign up to request clarification or add additional context in comments.

Comments

1

std::string is actually a typedef for std::basic_string<char>. You can use std::basic_string<BYTE> instead, and most (all?) std::string functionality, in particular .find(), will just work.

Comments

1

If you don't want to use existing library functions, implement your favorite generic string matching algorithm, for example Knuth-Morris-Pratt, Boyer-Moore or Rabin-Karp.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.