I have a pointer to a struct that contains a pointer to a short value. The following is the struct.
typedef struct {
short *val;
} x;
If I have a pointer to a variable of type x, I can dereference it and access an element of the struct by doing x->val
, but since val is a pointer as well, this only gives me the adress of val. How can I dereference this to access the value of val? I tried *(x->val)
, but that is not working. Or should it work like this, and my mistake has to be something entirely different?