Name | Description | Notes | Source | Availability | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
memchr() |
Search memory | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
memcmp() |
Compare memory | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
memcpy() |
Copy memory | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
memcpy_s() |
Copy memory | ? | (·) | <string.h> |
C11 | ||||||
memmove() |
Copy overlapping memory | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
memmove_s() |
Copy overlapping memory | ? | (·) | <string.h> |
C11 | ||||||
memset() |
Initialize memory | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
wmemchr() |
Search wide-character memory | (·) | <wchar.h> |
C95 | C99 | C11 | |||||
wmemcmp() |
Compare wide-character memory | (·) | <wchar.h> |
C95 | C99 | C11 | |||||
wmemcpy() |
Copy wide-character memory | (·) | <wchar.h> |
C95 | C99 | C11 | |||||
wmemcpy_s() |
Copy wide-character memory | ? | (·) | <wchar.h> |
C11 | ||||||
wmemmove() |
Copy overlapping wide-character memory | (·) | <wchar.h> |
C95 | C99 | C11 | |||||
wmemmove_s() |
Copy overlapping wide-character memory | ? | (·) | <wchar.h> |
C11 | ||||||
wmemset() |
Initialize wide-character memory | (·) | <wchar.h> |
C95 | C99 | C11 |
Functions with names matching ^mem[a-z]
might be added to <string.h>
.
#include <string.h>
void *memset(void *dst, int src, size_t len);
#include <wchar.h>
wchar_t *wmemset(wchar_t *dst, wchar_t src, size_t len);
These functions set len
elements of
an array of bytes
or wide characters
starting at dst
to src
. They return dst
.
#include <string.h>
void *memcpy(void *dst, const void *src, size_t srclen);
void *memmove(void *dst, const void *src, size_t srclen);
#define __STDC_WANT_ 1 #includeLIB_ EXT1__ <string.h>
errno_t memcpy_s(void *dst, rsize_t dstlen, const void *src, rsize_t srclen); errno_t memmove_s(void *dst, rsize_t dstlen, const void *src, rsize_t srclen);
#include <wchar.h>
wchar_t *wmemcpy(wchar_t *dst, const wchar_t *src, size_t srclen);
wchar_t *wmemmove(wchar_t *dst, const wchar_t *src, size_t srclen);
#define __STDC_WANT_ 1 #includeLIB_ EXT1__ <wchar.h>
errno_t wmemcpy_s(void *dst, rsize_t dstlen, const wchar_t *src, rsize_t srclen); errno_t wmemmove_s(void *dst, rsize_t dstlen, const wchar_t *src, rsize_t srclen);
These functions copy an array of srclen
bytes or wide characters starting at src
to an array starting at dst
.
The memmove
functions can cope with
the two arrays overlapping. For the other functions, the
behaviour is undefined.
The functions ending with _s
return
zero on success. They fail if dstlen
is less than srclen
, or if either is
greater than RSIZE_
. On failure,
they set the first dstlen
elements of
dst
to zero, and return non-zero. The
other functions return dst
.
#include <string.h>
void *memchr(void *hstk, int ndl, size_t hstklen);
int memcmp(const void *left, const void *right, size_t len);
#include <wchar.h>
wchar_t *wmemchr(wchar_t *hstk, wchar_t ndl, size_t hstklen);
int wmemcmp(const wchar_t *left, const wchar_t *right, size_t len);
The functions memchr
and
wmemchr
search an array of hstklen
bytes or wide characters starting at hstk
, and return a pointer to the first occurance
of ndl
, or NULL
if not found.
The functions memcmp
and
wmemcmp
compare two arrays each of len
bytes or wide characters starting at left
and right
, and return
zero if they are identical. Otherwise, the first
non-identical pair of elements are compared, and either a
positive value is returned if the element from left
is greater than the element from right
, or a negative value is returned.