home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!gossip.pyramid.com!pyramid!oracle!unrepliable!bounce
- From: wkaufman@us.oracle.com (William Kaufman)
- Newsgroups: comp.lang.c
- Subject: Re: Why should POINTERS be so damn hard to understand ?
- Message-ID: <1992Sep4.023823.6902@oracle.us.oracle.com>
- Date: 4 Sep 92 02:38:23 GMT
- References: <1992Aug27.135946.6622@infonode.ingr.com> <1992Aug28.163724.11581@mccc.edu> <Btx3II.Fyn@multisys.com>
- Sender: usenet@oracle.us.oracle.com (Oracle News Poster)
- Organization: Oracle Corporation, Redwood Shores CA
- Lines: 58
- Nntp-Posting-Host: hqsun2.us.oracle.com
- X-Disclaimer: This message was written by an unauthenticated user
- at Oracle Corporation. The opinions expressed are those
- of the user and not necessarily those of Oracle.
-
- In article <Btx3II.Fyn@multisys.com> rot@multisys.com (Republic of Taiwan) writes:
- ] =In article <1992Aug27.135946.6622@infonode.ingr.com> henders@infonode.ingr.com (Greg Henderson) writes:
- ]
- [...Greg posts an array scan and a pointer scan, deleted for brevity...]
- ]
- ] The presumption here is that the length of int is same as
- ] the length of the address space.
-
- How do you mean "address space"? You mean alignment or the size of
- the addressable area of memory considered as an integer? I don't think
- either should mess you up here.
-
- Also, I'm not sure which program you're objecting to. There are two
- here.
-
- In article <1992Aug27.135946.6622@infonode.ingr.com> henders@infonode.ingr.com (Greg Henderson) writes:
- =
- ={
- = int a[1000], *_i;
- =
- = for (_i=a; _i<a+1000; _i++ )
- = *_i = get_some_arbitrary_value();
- =}
-
- I assume this is the one, right? Well, by ANSI (and all pre-ANSI
- compilers that I've seen), a[] must be a *contiguous* set of int's, and
- _i must get initialized to &a[0]. So after _i++, _i must point to a[1],
- no?
-
- The only objection I have is "_i": ANSI says that starting
- identifiers with underscores a no-no. (Unless you're personally writing
- the compiler,...)
-
- ] If the int is 4 byte long and the address space is 2(or 8 or 3) byte long,
- ] the this fell miserably. The second one is not portable.
-
- If by "address space" you mean alignment, then it must be the case
- that
- (&a[1] - &a[0])
- is 4 (or 8 or 4, by your examples), and
- ((_i = a, ++_i) - &a[0])
- must also be 4 (or 8 or 4).
-
- (And, c.l.c fans, quote me no sequence points: the last expression
- was just for example, and would be used by no one in their right mind.
- It only fails if you don't understand what I mean, not if it doesn't
- produce a good run-time value.)
-
- If by "address space" you mean the addressable area of memory,
- declaring "int a[1000]" will either succeed (in which case, a[1000] will
- point to valid memory), or the program will crash on an "out of stack"
- error, or it will fail to compile/link.
-
- -- Bill K.
-
- Bill Kaufman, | "...all conscious species are plastic and
- Corporate Lackey | all plastic species are conscious."
- wkaufman@us.oracle.com | -- Yew-Kwang Ng
-