On this page
memmove
Prev: memcpy | Up: string.h | Next: memset
Rel: string.h, stdlib.h & string.h Guide
Ref: cppreference — memmove
Tags: #public #prog #c #stdlib #string #tier/core
Include
#include <string.h>
Signature & Overview
void *memmove(void *dst, const void *src, size_t n);
Copies n bytes from src to dst safely even when the memory regions overlap.
Notes & Pitfalls
- Safe on overlapping buffers: Use
memmove()when shifting elements left/right within the same array.
Example
#include <assert.h>
#include <string.h>
int main(void) {
char s[] = "abcdef";
memmove(s + 2, s, 4); // overlaps safely
assert(memcmp(s, "ababcd", 6) == 0);
}
Linked from
Related notes
- tuts/c/stdlib/string/memcpy Linked here; links to this page; shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/memset Linked here; links to this page; shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string Linked here; links to this page; shared tags: #c, #prog, #stdlib, #string
- tuts/c/stdlib/stdlib_and_string_h Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/string/memchr shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/memcmp shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/strcat shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/strchr shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/strcmp shared tags: #c, #prog, #stdlib, #string, #tier
- tuts/c/stdlib/string/strcpy shared tags: #c, #prog, #stdlib, #string, #tier