| <html lang="en"> |
| <head> |
| <title>memmem - Untitled</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Untitled"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Strings.html#Strings" title="Strings"> |
| <link rel="prev" href="memcpy.html#memcpy" title="memcpy"> |
| <link rel="next" href="memmove.html#memmove" title="memmove"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="memmem"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="memmove.html#memmove">memmove</a>, |
| Previous: <a rel="previous" accesskey="p" href="memcpy.html#memcpy">memcpy</a>, |
| Up: <a rel="up" accesskey="u" href="Strings.html#Strings">Strings</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">5.9 <code>memmem</code>—find memory segment</h3> |
| |
| <p><a name="index-memmem-378"></a><strong>Synopsis</strong> |
| <pre class="example"> #include <string.h> |
| char *memmem(const void *<var>s1</var>, size_t <var>l1</var>, const void *<var>s2</var>, |
| size_t <var>l2</var>); |
| |
| </pre> |
| <p><strong>Description</strong><br> |
| |
| <p>Locates the first occurrence in the memory region pointed to |
| by <var>s1</var> with length <var>l1</var> of the sequence of bytes pointed |
| to by <var>s2</var> of length <var>l2</var>. If you already know the |
| lengths of your haystack and needle, <code>memmem</code> can be much |
| faster than <code>strstr</code>. |
| |
| <p><br> |
| <strong>Returns</strong><br> |
| Returns a pointer to the located segment, or a null pointer if |
| <var>s2</var> is not found. If <var>l2</var> is 0, <var>s1</var> is returned. |
| |
| <p><br> |
| <strong>Portability</strong><br> |
| <code>memmem</code> is a newlib extension. |
| |
| <p><code>memmem</code> requires no supporting OS subroutines. |
| |
| <p><br> |
| |
| </body></html> |
| |