I am trying to figure out how to use memory blocks and create a block of data that contains different data types within it.
In my particular example I want a pointer to a memory block that contains a struct followed by an array of floats. This is what I'm trying:
char *memory_block; float *array_of_floats; /* pretend this is filled out, with num_of_float = # of elements */ struct str_type *ptr_str_type = malloc(sizeof(struct str_type); /* pretend struct members filled out */ memcpy(memory_block,ptr_str_type,sizeof(struct str_type)); memcpy(memory_block+sizeof(struct str_type),array_of_floats,sizeof(float)*num_of_float);
Is this supposed to work(tried using this)? Is it the right way for going about it?
When looking at *memory_block in debugger, what should I be seeing?