MicrOS
memchr.c File Reference
#include "../string.h"

Functions

void * memchr (void *ptr, int value, size_t num)
 Locate character in block of memory. More...
 

Function Documentation

◆ memchr()

void* memchr ( void *  ptr,
int  value,
size_t  num 
)

Locate character in block of memory.

Searches within the first num bytes of the block of memory pointed by ptr for the first occurrence of value (interpreted as an unsigned char), and returns a pointer to it.

Parameters
ptrPointer to the block of memory where the search is performed.
valueValue to be located. The value is passed as an int, but the function performs a byte per byte search using the unsigned char conversion of this value.
numNumber of bytes to be analyzed.
Returns
A pointer to the first occurrence of value in the block of memory pointed by ptr. If the value is not found, the function returns a null pointer.