C++ cstring memmove() function
Example
Copy four integers from one position to another:
int myNumbers[6] = {10, 20, 30, 40, 50, 60};
cout << "Before:\n";
for (int i = 0; i < 6; i++) {
cout << myNumbers[i] << " ";
}
memmove(&myNumbers[0], &myNumbers[2], 4*sizeof(myNumbers[0]));
cout << "\nAfter:\n";
for (int i = 0; i < 6; i++) {
cout << myNumbers[i] << " ";
}
Try it Yourself »
Definition and Usage
The memmove()
function copies data from one block of memory to another but accounts for overlapping memory.
The memmove()
function is defined in the <cstring>
header file.
Syntax
memmove(void * destination, void * source, size_t size);
The size_t
data type is a positive integer.
Parameter Values
Parameter | Description |
---|---|
destination | Required. A pointer to the block of memory to be copied to. |
source | Required. A pointer to the block of memory being copied. |
size | Required. The amount of data to copy measured in bytes. |
Technical Details
Returns: | A void type pointer to the destination. |
---|