memmove
Copy byte string
Description
The memmove function copies \c len bytes from string \c src to string \c dst. The two strings may overlap; the copy is always done in a non-destructive manner.Example:
Example - Copy byte string
Workings
#include <stdio.h> #include <string.h> int main() { // define the array u int u[6] = {1, 2, 3, 4, 5}; // copy u to u + 1 (these arrays overlap) memmove(u + 1, u, 5*sizeof(int)); // display u for (int i = 0; i < 6; ++i) printf("u[%d] = %d\n", i, u[i]); return 0; }
Solution
Output:
u[0] = 1 u[1] = 1 u[2] = 2 u[3] = 3 u[4] = 4 u[5] = 5