Memmove function in C
Void function * memmove (void * str1, const void * str2, size_t n) Copy n characters from str2 to str1, but to solve the matching of memory blocks, memmove () is a safe approach more than memcpy ().
Void function * memmove (void * str1, const void * str2, size_t n) Copy n characters from str2 to str1, but to solve the matching of memory blocks, memmove () is a safe approach more than memcpy ().
Declare memmove function in C
Below is the declaration for memmove () in C:
void * memmove ( void * str1 , const void * str2 , size_t n )
Parameters
str1 - This is the pointer to the destination array, where the content to be copied, cast into a pointer of type void *.
str2 - This is the pointer to the data source to copy, cast into a pointer of type void *.
n - This is the number of bytes to be copied.
Returns the value
This function returns a pointer to the destination string, str1.
For example
The following program C illustrates the usage of memmove () in C:
#include #include int main () { char str [] = "Vi du ham memmove trong C" ; memmove ( str + 20 , str + 15 , 11 ); puts ( str ); return 0 ; }
Compiling and running the above C program will result:
According to Tutorialspoint
Last lesson: Function memcpy () in C
Next lesson: memset () function in C
You should read it
- Memset () function in C
- The strrchr () function in C
- Strcpy () function in C
- Function strxfrm () in C
- The strcoll () function in C
- The function strcmp () in C
- The function strncmp () in C
- The strstr () function in C
- The function strpbrk () in C
- The strtok () function in C
- Strcat function in C
- The strlen () function in C
Maybe you are interested
Revealing new findings about the size of the galaxy Admire incredibly detailed images of the Orion Nebula through the eyes of the James Webb telescope This star 'tears up' its companion to create a rare beautiful nebula Galaxy merger moment gives glimpse into Milky Way's future Science has discovered the fastest-flying star in the Milky Way, reaching 8% of the speed of light Discovered organic molecules that can make life in the center of the Milky Way