Link to home
Start Free TrialLog in
Avatar of marvinm
marvinm

asked on

typedef*

If I have a structure
typedef struct {
   int i;
   int j;
   int k;
} MYSTRUCT;
And I want to declare a type that is a pointer to MYSTRUCT,
which is the preferable way and why (or are these the same)?
typedef MYSTRUCT* PMYSTRUCT;
or
typedef MYSTRUCT *PMYSTRUCT;
Thank You
Avatar of scrapdog
scrapdog
Flag of United States of America image

Both styles declare the exact same thing.  I don't see an advantage of one over the other, however

typedef MYSTRUCT *PMYSTRUCT

seems much more common.
Avatar of cox
cox

same thing, the compiler will make the same thing with both styles.
Cox:  is that not more or less what I said?
Avatar of marvinm

ASKER

scrapdog is correct. Your answers are the same.
I thought that both typdefs should be the same. I have seen it done both ways and was just wondering which was preferable.
scrapdog, if you lock this I will grade your response.
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Both the pointer reference is same.