Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!joefritz From: joefritz@pawl.rpi.edu (Jochen M. Fritz) Newsgroups: comp.lang.c Subject: Re: A "How to typedef..." Question Message-ID: <^20$~8#@rpi.edu> Date: 8 Aug 90 20:07:01 GMT References: Distribution: comp Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 33 In article fsf@kasparov.scs.com (Rick Farnbach) writes: >How does one create a type, using typedef, that is defined to be a >pointer to a pointer to a pointer... ad infinitum? The straight-forward >approach is: > > typedef tree *tree[2]; /* binary tree, for example */ > this is taken from a project I am working on and it does work. In my application I know how deep the tree can be at most, and if it is not that deep, branch.next.Left == NULL typedef union tree { struct leaf { /*the data that you have goes here */ } leaf; struct branch { /*this builds the linkage field*/ union basetree * Left; union basetree * Right; } branch; } tree; ------------------------------------------------------------------------ | Jochen Fritz | For though we live in the world, we do not | | joefritz@pawl.rpi.edu | wage war as the world does.-- 2 Cor. 10:3 | | usergk2s@rpitsmts.bitnet| You have heard it said, Love your neighbor | | Noah [the peace monger] | and hate your enemy. But I tell you: Love | | | your enemies. Matt. 5:43-44 | ------------------------------------------------------------------------