Solved

typedef*

Posted on 1998-12-29
6
473 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
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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 50 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C#, VS15, StructLayout 1 135
Grammars for C C++ and java 1 131
valid enum? 6 75
If a cell in a range equals "YES" return specific Test. 4 37
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

820 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