On this page
  1. memmove
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

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

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