#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char *c = "abc";
char *d = new char[sizeof(c)+1];
strcpy(d,c);
d[sizeof(d)-1]='\0';
cout << "strcpy c to d:" << d << endl;
char e[10];
memset(e,'3',5);
cout << "memset:" << e << endl;
char f[11];
memcpy(f,e,sizeof(e));
cout << "memcpy from e to f:" << f << endl;
char g[10];
memmove(g,f,sizeof(g));
cout << "memmove f to g,f:" << f << endl;
cout << "memmove f to g,g:" << g << endl;
cout << "diff memmove and memcopy:" << endl;
int h[10] = {1,2,3,4,5,6,7,8,9,10};
memmove(&h[4],h,sizeof(int)*6);
cout << "memmove:";
for(int i=0;i<sizeof(h)/sizeof(int);i++)
cout << h[i] << " ";
cout << endl;
int j[10] = {1,2,3,4,5,6,7,8,9,10};
memcpy(&j[4],j,sizeof(int)*6);
cout << "memcpy:";
for(int i=0;i<sizeof(j)/sizeof(int);i++)
cout << j[i] << " ";
cout << endl;
}
strcpy c to d:abc
memset:33333
memcpy from e to f:33333
memmove f to g,f:33333
memmove f to g,g:33333
diff memmove and memcopy:
memmove:1 2 3 4 1 2 3 4 5 6
memcpy:1 2 3 4 1 2 3 4 1 2