memmem() STL way?
问题 Is there an STL algorithm which can be used to search a sequence of bytes inside a buffer like memmem() does? 回答1: I don't know if this is good code, but the following works, using std::search: #include <cstdio> #include <string.h> #include <algorithm> int main(int argc, char **argv) { char *a = argv[0]; char *a_end = a + strlen(a); char *match = "out"; char *match_end = match+strlen(match); // If match contained nulls, you would have to know its length. char *res = std::search(a, a_end,