Thursday, 30 May 2013

The memcpy Function in C

  The function memcpy( ) is defined in the header file <string.h>. The prototype of the function memcpy( ) is as follows.

void * memcpy(void* destination,const void* source,size_t num);

The function memcpy( ) copies the values of num bytes from the location pointed by source directly to the memory block pointed by destination. 

#include <string.h>

int main()
    int abc[ ] = {111, 222, 333};
    int copy[3],i;
    memcpy(copy, abc, sizeof(int)*3);
    abc[0] = 444;
    printf("\nArray abc is :");
    printf("\nArray copy is :");
    return 0;

Click here to download the C Program. 

No comments:

Post a Comment