home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 13204 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  3.0 KB

  1. Path: sparky!uunet!olivea!gossip.pyramid.com!pyramid!oracle!unrepliable!bounce
  2. From: wkaufman@us.oracle.com (William Kaufman)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Why should POINTERS be so damn hard to understand ?
  5. Message-ID: <1992Sep4.023823.6902@oracle.us.oracle.com>
  6. Date: 4 Sep 92 02:38:23 GMT
  7. References: <1992Aug27.135946.6622@infonode.ingr.com> <1992Aug28.163724.11581@mccc.edu> <Btx3II.Fyn@multisys.com>
  8. Sender: usenet@oracle.us.oracle.com (Oracle News Poster)
  9. Organization: Oracle Corporation, Redwood Shores CA
  10. Lines: 58
  11. Nntp-Posting-Host: hqsun2.us.oracle.com
  12. X-Disclaimer: This message was written by an unauthenticated user
  13.               at Oracle Corporation.  The opinions expressed are those
  14.               of the user and not necessarily those of Oracle.
  15.  
  16. In article <Btx3II.Fyn@multisys.com> rot@multisys.com (Republic of Taiwan) writes:
  17. ] =In article <1992Aug27.135946.6622@infonode.ingr.com> henders@infonode.ingr.com (Greg Henderson) writes:
  18. [...Greg posts an array scan and a pointer scan, deleted for brevity...]
  19. ]
  20. ] The presumption here is that the length of int is same as
  21. ] the length of the address space.
  22.  
  23.     How do you mean "address space"?  You mean alignment or the size of
  24. the addressable area of memory considered as an integer?  I don't think
  25. either should mess you up here.
  26.  
  27.     Also, I'm not sure which program you're objecting to.  There are two
  28. here.
  29.  
  30. In article <1992Aug27.135946.6622@infonode.ingr.com> henders@infonode.ingr.com (Greg Henderson) writes:
  31. =
  32. ={
  33. =    int a[1000], *_i;
  34. =
  35. =    for (_i=a;  _i<a+1000; _i++ )
  36. =    *_i = get_some_arbitrary_value();
  37. =}
  38.  
  39.     I assume this is the one, right?  Well, by ANSI (and all pre-ANSI
  40. compilers that I've seen), a[] must be a *contiguous* set of int's, and
  41. _i must get initialized to &a[0].  So after _i++, _i must point to a[1],
  42. no?
  43.  
  44.     The only objection I have is "_i": ANSI says that starting
  45. identifiers with underscores a no-no.  (Unless you're personally writing
  46. the compiler,...)
  47.  
  48. ] If the int is 4 byte long and the address space is 2(or 8 or 3) byte long,
  49. ] the this fell miserably. The second one is not portable.
  50.  
  51.     If by "address space" you mean alignment, then it must be the case
  52. that
  53.         (&a[1] - &a[0])
  54. is 4 (or 8 or 4, by your examples), and
  55.         ((_i = a, ++_i) - &a[0])
  56. must also be 4 (or 8 or 4).
  57.  
  58.     (And, c.l.c fans, quote me no sequence points: the last expression
  59. was just for example, and would be used by no one in their right mind.
  60. It only fails if you don't understand what I mean, not if it doesn't
  61. produce a good run-time value.)
  62.  
  63.     If by "address space" you mean the addressable area of memory,
  64. declaring "int a[1000]" will either succeed (in which case, a[1000] will
  65. point to valid memory), or the program will crash on an "out of stack"
  66. error, or it will fail to compile/link.
  67.  
  68.                                            -- Bill K.
  69.  
  70. Bill Kaufman,          | "...all conscious species are plastic and
  71. Corporate Lackey       |  all plastic species are conscious."
  72. wkaufman@us.oracle.com |                     -- Yew-Kwang Ng
  73.