{{keywords>wiki library source code example reference}}
===== memmove =====
#include
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 C Sourcecode Example =====
/*
* memmove example code
* http://code-reference.com/c/string.h/memmove
*/
#include
#include
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;
}
==== output of memmove c example ====
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