Tiny portable implementations of standard library functions. More...
#include <stddef.h>
Functions | |
void * | memset (void *ptr, int value, size_t num) |
Fill block of memory. More... | |
int | memcmp (const void *ptr1, const void *ptr2, size_t num) |
Compare two blocks of memory. More... | |
Tiny portable implementations of standard library functions.
int memcmp | ( | const void * | ptr1, |
const void * | ptr2, | ||
size_t | num | ||
) |
Compare two blocks of memory.
Compares the first num bytes of the block of memory pointed by ptr1 to the first num bytes pointed by ptr2, returning zero if they all match or a value different from zero representing which is greater if they do not.
Notice that, unlike strcmp, the function does not stop comparing after finding a null character.
ptr1 | Pointer to block of memory. |
ptr2 | Pointer to block of memory. |
num | Number of bytes to compare. |
<0 | the first byte that does not match in both memory blocks has a lower value in ptr1 than in ptr2 (if evaluated as unsigned char values) |
0 | the contents of both memory blocks are equal |
>0 | the first byte that does not match in both memory blocks has a greater value in ptr1 than in ptr2 (if evaluated as unsigned char values) |
void* memset | ( | void * | ptr, |
int | value, | ||
size_t | num | ||
) |
Fill block of memory.
Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char)
ptr | Pointer to the block of memory to fill. |
value | Value to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value. |
num | Number of bytes to be set to the value. size_t is an unsigned integral type. |