home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / programm / 3084 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  1.1 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!sun-barr!sh.wide!fgw!fdm!ace!melby
  2. From: melby@dove.yk.Fujitsu.CO.JP (John B. Melby)
  3. Newsgroups: comp.programming
  4. Subject: Re: Mutual reference in C?
  5. Message-ID: <MELBY.92Nov9050854@dove.yk.Fujitsu.CO.JP>
  6. Date: 9 Nov 92 05:08:54 GMT
  7. References: <1djb0tINNa9t@morrow.stanford.edu>
  8. Sender: news@ace.yk.fujitsu.co.jp
  9. Organization: Open Systems Dept. Div. 2 Sect. 1, FUJITSU LTD.
  10. Lines: 29
  11. In-reply-to: ehh@camis.Stanford.EDU's message of 9 Nov 92 00:16:45 JST
  12. Followups-To: comp.lang.c
  13.  
  14. >if there are two structures, a and b, that refer to each other,
  15. >struct {
  16. >        b       *bPtr;
  17. >} a;
  18. >
  19. >and
  20. >
  21. >struct {
  22. >        a       *aPtr;
  23. >} b;
  24. >
  25. >how can i declare these two structures such that they can refer to pointers
  26. >of each other?
  27.  
  28. You can declare your structs as follows, assigning a name to each struct
  29. that gets referenced in another declaration:
  30.  
  31. typedef struct _a {
  32.     struct _b *bPtr;
  33. } a;
  34.  
  35. typedef struct _b {
  36.     struct _a *aPtr;
  37. } b;
  38.  
  39. -----
  40. John B. Melby
  41. Fujitsu Limited, Yokohama
  42. melby@yk.fujitsu.co.jp
  43.