To “copy and paste” we use memcpy and memmove depending on whether the src and dest overlap, right?
Is there an encapsulated function for “cut and paste”?
If not, is there a relatively well-defined way to achieve that? Only way I can think of is to memset the redundant part to 0 after memmove.
To clarify by code, by mem_xxx, I want the array named arr to be “2345”, instead of “234545” if use memmove.
<code>char *arr = new char[8];
for ( int i = 2; i <= 5; i++ ) {
arr[i] = char( i );
}
mem_xxx( arr, arr + 2, 5 - 2 + 1 );
</code>
<code>char *arr = new char[8];
for ( int i = 2; i <= 5; i++ ) {
arr[i] = char( i );
}
mem_xxx( arr, arr + 2, 5 - 2 + 1 );
</code>
char *arr = new char[8];
for ( int i = 2; i <= 5; i++ ) {
arr[i] = char( i );
}
mem_xxx( arr, arr + 2, 5 - 2 + 1 );
1