Another silly question
Sean Kelly
kelly at nmtsun.nmt.edu
Thu Apr 27 08:57:40 AEST 1989
My CS instructor and I disagree about a certain moot point. I have a text
book which says that
*(a + i) and a[i]
are equivalent, given an array a, and int index i ... each gives the
value stored in a[i]. But he says that
*(a + i)
is non-standard and would not expect it do go far on all _real_ C compilers
(_real_ meaning those compilers that are somewhat devoted to K & R or ANSI).
He expects that many compilers would instead add the value of i to the
pointer a, and then reference the item stored there. I say that the
compiler's smart enough to realize what we're trying to achieve, and
won't do something like
* (char *) ( (int) a + i )
which he thinks it will probably do on most machines. It doesn't on our
Suns nor our VAX.
I don't have a copy of K&R's book, first or new edition, just _Programming_
_in_C_ by S. Kochan, which seems pretty valid.
What do you think?
--
Sean Kelly I'm not a number, I am a free man!
kelly at nmtsun.nmt.edu --The Prisoner
--
More information about the Comp.lang.c
mailing list