Struct definition in MS-C

D. Chadwick Gibbons chad at csd4.csd.uwm.edu
Tue Aug 22 00:47:44 AEST 1989


In article <1575 at dsacg3.UUCP> nts0302 at dsacg3.UUCP (Bob Fisher) writes:
|From article <680010 at hpmwjaa.HP.COM>, by jeffa at hpmwtd.HP.COM (Jeff Aguilera):
|#> struct node {
|## 	struct node *next;
|## 	};
|## as it is with standard C, but this doesn't work with MS-C.
|I doubt it.  struct node cannot include itself in its own definition.

	..but it can indeed contain a pointer to itself.  This is a valid C
construction, and is mentioned fairly early in the "Structures" chapter of
K&R.  Without this, data structures such as b-trees would be impossible.

struct _btree {
    char *datum;
    struct _btree *left, *right;
};
--
D. Chadwick Gibbons |  Internet: chad at csd4.csd.uwm.edu



More information about the Comp.lang.c mailing list