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
4 Mistakes to Avoid When Setting Up a Password Manager
How to avoid grainy photos on smartphones
11 common mistakes when building a PC and how to avoid them
Build DTCL Void squad season 9
7 mistakes on social networks to avoid if you want to protect your privacy
4 Android features to help avoid distractions at work