home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / c / 12410 < prev    next >
Encoding:
Internet Message Format  |  1992-08-16  |  1.8 KB

  1. Path: sparky!uunet!psinntp!dg-rtp!sheol!throopw
  2. From: throopw@sheol.UUCP (Wayne Throop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Computer terms, etc
  5. Summary: may still be missing the point
  6. Message-ID: <714017938@sheol.UUCP>
  7. Date: 17 Aug 92 02:16:11 GMT
  8. References: <cee1.713424953@Isis.MsState.Edu> <19479@fritz.filenet.com> <1992Aug13.192456.19127@Synopsys.Com> <19590@fritz.filenet.com>
  9. Lines: 35
  10.  
  11. -> From: scotth@felix.filenet.com (Scott Hopson)
  12. -> Message-ID: <19590@fritz.filenet.com>
  13. ->>> *foo[] is a pointer to an array
  14. ->> No, it's an array of pointers, because [] has higher precedence than *.
  15. -> Sorry, it was 2:00 AM when I wrote that, I guess I forgot to put
  16. -> "of pointers" on the end.
  17. ->
  18. -> *foo[] is a pointer to an array [of pointers]
  19. ->
  20. -> thanks for the correction.
  21.  
  22. Um... I think Scott is still missing out on exactly what he's being
  23. corrected upon.  Objects type (*foo[]) are not pointers in any way,
  24. shape, or form.  They are arrays.  Again: the object named "foo" by
  25. the above declaration is NOT A POINTER (though it sometimes
  26. plays one in certain expressions).
  27.  
  28. To convince yourself that this is so, consider the results of
  29. applying sizeof to such an object.
  30.  
  31. Now, with that said, if such a type is declared to be a formal
  32. parameter, it is "rewritten" by the compiler to be of type (char**).  
  33. In which case the type is "pointer to pointers to chars", no array
  34. involved. 
  35.  
  36. Hear me now and understand me later:
  37.  
  38. Renounce the foul heresy that "array declarations really declare
  39. constant pointers in C", firstly because it is the Font of Many Errors,
  40. and leads inevitably to Bad Code, but also because it isn't true.  If
  41. you don't renounce this heresy, I prophesy that Subtle Pointer Bugs will
  42. hound you all the days of your programming life.  YOU have been WARNED. 
  43.  
  44. --
  45. Wayne Throop  ...!mcnc!dg-rtp!sheol!throopw
  46.