Using memmove to copy the last 10 bytes of array x into the first 10 bytes of array x. - C++ Data Type

C++ examples for Data Type:char array

Description

Using memmove to copy the last 10 bytes of array x into the first 10 bytes of array x.

Demo Code

#include <iostream> 
#include <cstring> // memmove prototype 
using namespace std; 

int main() /*from  www . ja v a  2 s .  c o  m*/
{ 
    char x[] = "this is a test"; 

    cout << "The string in array x before memmove is: " << x; 
    cout << "\nThe string in array x after memmove is:                " 
        << static_cast< char * >( memmove( x, &x[ 5 ], 10 ) ) << endl; 
    
    return 0;
}

Result


Related Tutorials