Article View: comp.lang.c.moderated
Article #2366Re: how do I typedef an array of pointers to a structure?
From: Ari Lukumies
Date: Sat, 23 Mar 1996 06:48
Date: Sat, 23 Mar 1996 06:48
44 lines
1913 bytes
1913 bytes
Timur Tabi wrote:
>
> Ok, I've changed things a little bit.
>
> This is the code I have now:
>
> class NODE;
>
> typedef NODE *PNODE; // PNODE is a pointer to a node
> typedef PNODE NODE_LINKS[]; // NODE_LINKS is an array of pointers to
> nodes
> typedef NODE_LINKS *PNODE_LINKS; // PNODE_LINKS is a pointer to a NODE_LINK
> typedef PNODE_LINKS NODE_SLOTS[]; // NODE_SLOTS is an array of PNODE_LINKS
> typedef NODE_SLOTS *PNODE_SLOTS; // PNODE_SLOTS is a pointer to a NODE_SLOT
>
[snip]
> Unfortunately, this setup gives me really screwy code. I'm tempted to throw
> this whole array thing out the window and just do something like
>
> typedef NODE ***PNODE_SLOTS;
>
> which is what I had way in the beginning. I guess my real question is:
>
> If I know something is a pointer to an array of pointers to an array of
> pointers to NODE's, can I treat them as a pointer to a pointer to a pointer to
> a NODE?
You could use:
typedef NODE *PNODE; // pointer to a node
typedef PNODE *NODE_SLOTS; // array of ptrs (size indetermined yet)
typedef PNODE_LINKS *PNODE_SLOTS; // likewise, array size yet indetermined
This would equal
typedef NODE ***PNODE_SLOTS;
which is what you're after.
Later,
AriL
--
All my opinions are mine and mine alone.
Technical Details
Message-ID:
<4j06sd$846@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4i804b$46u@solutions.solon.com> <4io1lf$ns1@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi> Newsgroups: comp.lang.c.moderated Subject: Re: how do I typedef an array of pointers to a structure? Date: 23 Mar 1996 00:48:45 -0600 Organization: Carelcomp Products Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4j06sd$846@solutions.solon.com> References: <4i804b$46u@solutions.solon.com> <4io1lf$ns1@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com X-Mailer: Mozilla 2.0 (WinNT; I)