C memmove() Function
C memmove() Function
The memmove()
function copies a block of memory from a location to another.
This function copies the data first to an intermediate buffer, then from buffer to destination. So, memmove() is slightly slower approach than memcpy().
This function doesn't overlap the source. So, memmove() is safer than memcpy().
Example
Output
Syntax
Parameter Values
Value | Type | Explanation |
---|---|---|
dest | Required | Destination array where the content is to be copied. |
src | Required | Source of data to be copied. |
n | Required | Number of bytes to be copied. |
Return Value
Value | Explanation |
---|---|
Address | Returns a pointer to the destination, which is dest array. |
More Examples
In the following example, the destination string is "cde" and the source string is "abcde". So, the memmove() function will replace "cde" with "abc" and the result is ababc.
Example
Output
In the following example, memcpy() overlaps the source, but memove() doesn't.
Example
Output
Reminder
Hi Developers, we almost covered 98% of String functions and Interview Question on C with examples for quick and easy learning.
We are working to cover every Single Concept in C.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.