0% found this document useful (0 votes)
74 views1 page

C Library Function - Memmove : Description

wgdf

Uploaded by

gannoju423
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views1 page

C Library Function - Memmove : Description

wgdf

Uploaded by

gannoju423
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

http://www.tutorialspoint.com/c_standard_library/c_function_memmove.htm Copyright tutorialspoint.

com
C LIBRARY FUNCTION - MEMMOVE()
Description
The C library function void *memmove(void *str1, const void *str2, size_t n) copies n characters
from str2 to str1, but for overlapping memory blocks, memmove() is a safer approach than memcpy().
Declaration
Following is the declaration for memmove() function.
void *memmove(void *str1, const void *str2, size_t n)
Parameters
str1 -- This is pointer to the destination array where the content is to be copied, type-casted to a pointer
of type void*.
str2 -- This is pointer to the source of data to be copied, type-casted to a pointer of type void*.
n -- This is the number of bytes to be copied.
Return Value
This function returns a pointer to destination, which is str1
Example
The following example shows the usage of memmove() function.
#include <stdio.h>
#include <string.h>
int main ()
{
const char dest[] = "oldstring";
const char src[] = "newstring";
printf("Before memmove dest = %s, src = %s\n", dest, src);
memmove(dest, src, 9);
printf("After memmove dest = %s, src = %s\n", dest, src);
return(0);
}
Let us compile and run the above program, this will produce the following result:
Before memmove dest = oldstring, src = newstring
After memmove dest = newstring, src = newstring

You might also like