Embedded Artistry Framework
Embedded Systems C++ Framework
Functions
strnstr.c File Reference
#include <string.h>
Include dependency graph for strnstr.c:

Functions

char * strnstr (const char *s, const char *find, size_t slen)
 Finds the first occurrence of find in the initial slen characters of the object pointed to by s. More...
 

Function Documentation

◆ strnstr()

char* strnstr ( const char *  s,
const char *  find,
size_t  slen 
)

Finds the first occurrence of find in the initial slen characters of the object pointed to by s.

Locates the first occurrence of the null-terminated string find in the string s, where not more than slen characters are searched. Characters that appear after a ‘\0’ character are not searched.

The behavior is undefined if either find or s is not a pointer to a null-terminated byte string.

Parameters
spointer to the null-terminated byte string to examine
findpointer to the null-terminated byte string to search for
slenmaxinum number of characters to search for
Returns
If find is an empty string, s is returned; if find occurs nowhere in s, NULL is returned; otherwise a pointer to the first character of the first occurrence of find is returned.

References NULL, s, sc, strlen(), and strncmp().

Referenced by strnstr_test(), and strnstr_test_null().

Here is the caller graph for this function: