C-Learning a specific memory address at runtime

Is it possible to dereference a void pointer without knowing the knowledge (at runtime) of the size of an element in memory? Or, if this is not possible with the void pointer, how can I access a specific memory address (on the heap) and read only a certain number of bytes known at run time?

+4
source share
1 answer

With char *, which basically indicates the size of a byte of memory, you can access all bytes of any type of data.

And you can also apply void *to the desired type and read it to get the correct dereferenced value.

+9

Source: https://habr.com/ru/post/1665191/


All Articles