Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C-Examining a specific memory adress during execution

Is it possible to dereference a void pointer without a cast knowing(during execution) the size of the item located in memory ? Or, if not possible with a void pointer, how can I access a specific memory address(located in the heap) and read an only-known during execution specific number of bytes ?

like image 817
Kyle Avatar asked Jan 04 '23 20:01

Kyle


1 Answers

With a char * which basically points to a byte size of memory you can access all the bytes of any datatype.

And you can also cast a void * to necessary type and deference it to get the correct dereferenced value.

like image 145
user2736738 Avatar answered Jan 13 '23 10:01

user2736738