memchr searches a specified memory region for a byte value. It takes the region, the value to find, and an explicit length, so the search is expressed over an array or memory range rather than as a string operation. section 6.1.5
Function form
The standard-library interface is declared as: void* memchr(const void *s, int c, size_t n); Here, s identifies the memory region, c supplies the byte value being searched for, and n supplies the region length.
TAKEAWAY
- Use memchr when the search range is described by an explicit length. section 6.1.5
- Distinguish memchr from string functions such as strlen and strcpy, which operate on null-terminated strings. section 6.1.5
