Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I reference an element in my structure...?

Status
Not open for further replies.

martindavey

Programmer
Jan 2, 2000
122
GB
I have the following structure:-


struct _ServiceKey {
int oper;
int dist;
int site;
char route[4+1];
} **ppServiceKey, *pFirstKey;


How do I reference an element (eg. oper) in this structure?
In dbx the following works ok:-


assign (**ppServiceKey)->oper = 5
print (**ppServiceKey)->oper


In my program I have:-

(**ppServiceKey)->oper = 5;

This gives me the compiliation error:-

...left operand of "->" must be pointer to struct/union...

Apologies if I'm being stupid.
 
It's ok. I've figured it out - duh.

(*ppServiceKey)->oper = 5;
 
Yes, you are right. Suppose you are using ** then you have to put . operator to access the member, because ppServiceKey is a ** variable.

Like

(**ppServiceKey).ope = 5;

Maniraja S



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top