![]() |
VOOZH | about |
The memcpy() function in C is used to copy a specified number of bytes from one memory location to another. It is widely used for copying arrays, structures, and blocks of memory efficiently.
Value of b before calling memcpy: 10 Value of b after calling memcpy: 20
Explanation
void *memcpy(void *to, const void *from, size_t numBytes);
Parameters
Return Value: Returns a pointer to the destination memory location (to).
Note: The source and destination memory regions must not overlap. If overlapping memory regions need to be copied, use memmove() instead.
The memcpy() function can also be used to copy the contents of one character array (string) to another.
str2 after memcpy:Geeks
Explanation
The memcpy() function is optimized for fast memory copying, but it has certain characteristics and limitations that should be understood to avoid unexpected behavior.