#include <stdio.h>
#include <string.h>
int main(void) {
char dest_arr[] = "DDDAAABBB";
// to , from , size
// in case of overlap behavior of memcpy is undefined.
printf("string before memcpy is %s \n", dest_arr
); memcpy( dest_arr
+ 3, dest_arr
, 6); printf("string after memcpy is %s \n", dest_arr
);
// retintialising the string.
strcpy(dest_arr
, "DDDAAABBB");
// note that memmove detects overlap of "AAA" and copy that first.
printf("string before memmove is %s \n", dest_arr
); memmove( dest_arr
+ 3, dest_arr
, 6); printf("string after memmove is %s \n\n", dest_arr
);
// use of memset
printf("string after using memset is %s \n\n", dest_arr
); }