I have code that looks like the following:
#include <stdio.h>
typedef struct SomeStruct* ptr;
main(){
printf("%lu\n",sizeof(ptr));
}
The given code will print the size of struct SomeStruct*. However I want sizeof(struct SomeStruct). If I don’t know beforehand the name of the struct, is there a way for me to still find the size of the struct pointed to by ptr?
If you have a variable with type
ptr, you can dereference it: