?
Solved

typedef*

Posted on 1998-12-29
6
Medium Priority
?
481 Views
Last Modified: 2010-04-15
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
0
Comment
Question by:marvinm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 1255463
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.
0
 
LVL 1

Expert Comment

by:cox
ID: 1255464
same thing, the compiler will make the same thing with both styles.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1255465
Cox:  is that not more or less what I said?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:marvinm
ID: 1255466
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.
0
 
LVL 5

Accepted Solution

by:
scrapdog earned 200 total points
ID: 1255467
Most people are probably accustomed to seeing

typedef MYSTRUCT *PMYSTRUCT

so maybe this way is preferable to make it easier to read.  However it is entirely up to you.
0
 

Expert Comment

by:sselvi
ID: 1255468
Both the pointer reference is same.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question