I want to use C to copy all content i from struct member indexs to struct A with memcpy. I don't know how to do that. Can you please show me how it done if even possible?
Let say we have 3 defined struct's:
struct A {
int destination[100];
};
struct B
{
int i;
};
struct C {
struct B ** indexs;
};
The idea is to get from struct C all member indexs and copy from indexs all the content of i to struct A:
struct A a;
struct C * tasks = calloc(2, sizeof(struct C));
tasks[0].indexs = (struct B **)calloc((size_t)5, sizeof(struct B *));
tasks[0].indexs[0] = malloc(sizeof (int));
tasks[0].indexs[1] = malloc(sizeof (int));
tasks[0].indexs[2] = malloc(sizeof (int));
tasks[0].indexs[3] = malloc(sizeof (int));
tasks[0].indexs[0]->i =1;
tasks[0].indexs[1]->i =2;
tasks[0].indexs[2]->i =3;
tasks[0].indexs[3]->i =4;
memcpy(&a.destination, &tasks[0].indexs[0]->i, 100 * sizeof (int));
printf("Hello World: %i ", a.destination[1]);