In C, the memmem
function is used to locate a particular sequence of bytes in a memory area. It can be assimilated to strstr
, which is dedicated t
Historically, that is before the first revision of the Standard, C has been made by compiler writers.
In the case of strstr
, it is a little bit different because it has been introduced by the C Committee, the C89 Rationale document tells us that:
"The
strstr
function is an invention of the Committee. It is included as a hook for efficient algorithms, or for built-in substring instruction."
The C Committee does not explain why it has not made a more general function not limited to strings so any reasoning may only be speculation. My only guess is the use case has been considered not important enough to have a generic memmem
instead of strstr
. Remember that in the goals of C there is this requirement (in the C99 Rationale) "Keep the language small and simple". Also even POSIX didn't consider it for inclusion.
In any case to my knowledge nobody has proposed any Defect Report or proposal to have memmem
included.