I have some binary data in a file and load the file into memory at char* data
. Now I know e.g. that at offset 123 begins a struct something
.
Is it safe to do the following
(struct something*) (data + 123) // ??&data [123]??
and then access members of the struct. Or should I do something like
struct something record;
memcpy (&record, data + 123, sizeof (struct something) );
Or even something completely different?
My question is mainly motivated, because I have some fuzzy recollections about "memory alignment", "word boundaries", etc...