Next: , Previous: , Up: Strings   [Contents][Index]


5.9 memmem—find memory segment

Synopsis

#include <string.h>
void *memmem(const void *s1, size_t l1, const void *s2,
    size_t l2);

Description

Locates the first occurrence in the memory region pointed to by s1 with length l1 of the sequence of bytes pointed to by s2 of length l2. If you already know the lengths of your haystack and needle, memmem is much faster than strstr.


Returns
Returns a pointer to the located segment, or a null pointer if s2 is not found. If l2 is 0, s1 is returned.


Portability
memmem is a newlib extension.

memmem requires no supporting OS subroutines.