home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!sun-barr!sh.wide!fgw!fdm!ace!melby
- From: melby@dove.yk.Fujitsu.CO.JP (John B. Melby)
- Newsgroups: comp.programming
- Subject: Re: Mutual reference in C?
- Message-ID: <MELBY.92Nov9050854@dove.yk.Fujitsu.CO.JP>
- Date: 9 Nov 92 05:08:54 GMT
- References: <1djb0tINNa9t@morrow.stanford.edu>
- Sender: news@ace.yk.fujitsu.co.jp
- Organization: Open Systems Dept. Div. 2 Sect. 1, FUJITSU LTD.
- Lines: 29
- In-reply-to: ehh@camis.Stanford.EDU's message of 9 Nov 92 00:16:45 JST
- Followups-To: comp.lang.c
-
- >if there are two structures, a and b, that refer to each other,
- >struct {
- > b *bPtr;
- >} a;
- >
- >and
- >
- >struct {
- > a *aPtr;
- >} b;
- >
- >how can i declare these two structures such that they can refer to pointers
- >of each other?
-
- You can declare your structs as follows, assigning a name to each struct
- that gets referenced in another declaration:
-
- typedef struct _a {
- struct _b *bPtr;
- } a;
-
- typedef struct _b {
- struct _a *aPtr;
- } b;
-
- -----
- John B. Melby
- Fujitsu Limited, Yokohama
- melby@yk.fujitsu.co.jp
-