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 ().
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
Dining room design mistakes to avoid
6 mistakes to avoid when using Gmail at work
How to Avoid Post-Tracking Targeted Ads After Shopping Online
The Truth About Salt: How to Avoid One of the World's Most Dangerous Silent Killers
8 Mistakes to Avoid on WhatsApp
10 Important Mistakes to Avoid When Maintaining Your Computer