Solved

typedef*

Posted on 1998-12-29
6
467 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Question has a verified solution.

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

Suggested Solutions

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
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 how to create, access, and change arrays in the C programming language.

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now