بله میشه Shallow Copy .
بره مثال اینو نگا کن :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct DADE
{
int shomar;
int* ints;
}DADE;
void copy_shallow (DADE* a,const DADE* b)
{
*a = *b;
}
void copy_deep (DADE* a,const DADE* b)
{
int andaze = b->shomar * sizeof(int);
a->ints = (int*) malloc (andaze);
memcpy(a->ints,b->ints,andaze);
}
void namayesh (const DADE* dade)
{
printf("---------------\n");
for(int i = 0;i < dade->shomar;i++)
printf("#%i = %i [0x%x]\n",i,dade->ints[i],&dade->ints[i]);
}
int main ()
{
DADE a,b;
a.shomar = 3;
a.ints = (int*) malloc (sizeof (int) * 3);
a.ints[0] = 10;
a.ints[1] = 20;
a.ints[2] = 30;
copy_shallow(&b,&a);
namayesh(&a);
namayesh(&b);
copy_deep(&b,&a);
namayesh(&a);
namayesh(&b);
getchar();
return 0;
}
Deep Copy همه ی محتویات شی داده شده رو هم میریزه توی شی تازه .