So I have a struct with arrays inside it like so:
struct struct1 {
unsigned char data1[32];
unsigned char data2[32];
char *id;
};
and a second struct defined as
typedef struct
{
uint8_t id;
uint8_t data1[32];
uint8_t data2[32];
} struct2;
Struct1 with data already inside it is passed to me via a function like so:
bool func1(struct struct1 * const struct1)
and I need to create a NEW struct2 and pass all the data from struct1 into it.
I thought I could just assign the pointers like so
struct2 *new_struct;
new_struct->id = struct1->id;
new_struct->data1 = struct1->data1;
new_struct->data2 = struct1->data2;
but I guess array pointers in C cannot be changed (or at least that's what I got from reading up on it).
So how do I create a new struct2 and pass the data I need into it from struct1?
memcpy(struct1->data1, new_struct->data1, size_of(struct1->data))