Programming Reference/Librarys
Question & Answer
Q&A is closed
#include <stdlib.h> void *memmove(void *str1, const void *str2, size_t n);
str1: target memory block (at least size bytes in size)
str2: source memory block (at least size bytes in size)
n: number of bytes to be copied (The type size_t corresponds usually int))
/* * memmove example code * http://code-reference.com/c/string.h/memmove */ #include <stdio.h> #include <string.h> int main ( void ) { char str[100] = "memmove example"; char str2[15]; int n; n = strlen(str); /* bytes to copy */ memmove( str2, str, n ); printf("\"move\" string str to str2 : "); puts( str2 ); printf("move str 40 bytes further : "); memmove(str+40, str, 15); puts(str); printf("move str 14 bytes further : "); memmove(str+8, str, 15); puts(str); return 0; }
user@host:~$ ./memmove
"move" string str to str2 : memmove example
move str 40 bytes further : memmove example
move str 14 bytes further : memmove memmove example