Suppose the memory address of a struct in C language is stored in a variable of sufficiently wide integer type, such as uintptr_t.
I want to read the contents of struct by casting the integer to a struct pointer and dereferencing that.
Can the original struct be reconstructed using this approach?
>Solution :
Instead of storing the memory location in any variable of datatypes like int or uintptr_t, you should simply use pointer to struct. Then the arrow operator can be used to access the content of this struct.
Suppose you have struct named info then pointer can be created as struct info *x = &info;