I have a struct like
struct T {
int *baseofint
}Tstruct, *pTstruct;
int one;
pTstruct pointer;
now i want to define
one = pointer.baseofint; //got filled with an integer;
error message: **operator is not equal to operand**
I also tried
one = *(pointer.baseofint);
error message:**operand of * is no pointer*
Maybe someone can help, thanks.
First of all, I don’t think the following code is what you think it is:
You’re declaring a structure type
struct T, and creating an instance of it calledTstructand a pointer to it calledpTstruct. But those aren’t types you’re creating, they’re variables. That makes thepTstruct pointer;invalid code, too. What you probably intended was a typedef:…to make
Tstructequivalent tostruct T, andpTstructequivalent tostruct T *.As for accessing and dereferencing the
baseofintfield, it’s slightly different depending on whether you’re accessing it through a pointer or not… but here’s how: