take a look at this code:
struct mystruct { int x; int y; }; void* mem = malloc ( sizeof mystruct ); mystruct s; s.x = 10; s.y = 20; memcpy ( mem, &s, sizeof mystruct );now ptr has the values of 10 and 20, what if i want to change the 20 to 30, without changing the 10?
the place where memcpy is being called from does not know what is mystruct, but it knows it's size and the sizes of it's components, how can i use memcpy to change y?
something like memcpy ( mem + offset, value, sizeof (int) );