Memory Block Management
The following functions declared in string.h are used to compare, search, or initialize memory buffers:
-
void *memchr( const void *buf, intc, size_tn); Searches the first
nbytes of the bufferbuffor the first occurrence of the characterc.-
void *memcmp( const void *s1, const void *s2, size_tn); Compares the first
nbytes in the buffers1with the corresponding bytes in the buffers2. The return value is less than, equal to, or greater than0to indicate whethers1is less than, equal to, or greater thans2.-
void *memcpy( void *dest, const void *src, size_tn); Copies
nbytes from the buffersrcto the bufferdest.-
void *memmove( void *dest, const void *src, size_tn); Copies
nbytes from the buffersrcto the bufferdest. In case the buffers overlap, every character is read before another character is written to the same location.-
void *memset( void *dest, intc, size_tn); Fills the first
nbytes of the bufferdestwith the characterc.
The corresponding wmem... functions, for handling
buffers of wide characters with type wchar_t, are
declared in the header file
wchar.h
(*).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access