"macluvitch" <ma********@hotmail.com> wrote:
I have an expression like this
(type *)var + 1
Wath heppens is I want to make a pointer to this
sth like ptr = &((type *)var + 1)
I know this is meaningless but I don't have the idea in mind
Well, it can't be done that way. You cannot take the address of an
expression result; expression results have no definite address in
memory. If you really need a pointer that points at that value, you'll
need to create an object of the appropriate type, assign the value to
that object, then get its address. Like this:
compatible_type var;
type *dummy, **ptr;
var=somevalue;
dummy=((type *)var + 1);
ptr=&dummy;
Since the value of a pointer does not depend on the value of what it
points at (think about it: does your address depend on your name? If you
change your name by deed poll, does your address change?), this is
correct, too:
compatible_type var;
type *dummy, **ptr=&dummy;
var=somevalue;
dummy=((type *)var + 1);
dummy needs to be of type "type *", because that is the type of the
cast, and therefore of the whole expression. ptr needs to be of type
"type **", because it points at dummy.
Richard