A "How to typedef..." Question

Jochen M. Fritz joefritz at pawl.rpi.edu
Thu Aug 9 06:07:01 AEST 1990


In article <FSF.90Aug6202518 at kasparov.scs.com> fsf at 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 at pawl.rpi.edu   | wage war as the world does.-- 2 Cor. 10:3  |      
| usergk2s at 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               |
------------------------------------------------------------------------



More information about the Comp.lang.c mailing list