home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / programm / 3082 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.1 KB  |  35 lines

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!stanford.edu!morrow.stanford.edu!camis.Stanford.EDU!ehh
  2. From: ehh@camis.Stanford.EDU (Edward H. Herskovits)
  3. Newsgroups: comp.programming
  4. Subject: Mutual reference in C?
  5. Date: 8 Nov 1992 15:16:45 GMT
  6. Organization: Stanford University School of Medicine
  7. Lines: 24
  8. Message-ID: <1djb0tINNa9t@morrow.stanford.edu>
  9. NNTP-Posting-Host: camis.stanford.edu
  10.  
  11.  
  12. simple question to which i couldn't find an answer in standard c books:
  13. if there are two structures, a and b, that refer to each other,
  14. struct {
  15.     ...
  16.     b    *bPtr;
  17.     ...
  18. } a;
  19.  
  20. and
  21.  
  22. struct {
  23.     ...
  24.     a    *aPtr;
  25.     ...
  26. } b;
  27.  
  28. how can i declare these two structures such that they can refer to pointers
  29. of each other? i know that self-referential structures can be declared with
  30. tags, but i can't get these declarations to compile no matter how i modify
  31. them. i know that in pascal (ugh) i could use the "forward" keyword; what
  32. would be the equivalent thing to do in c?
  33. please reply by email, since it's probably not of general interest.
  34. -eddie
  35.