Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!nmtsun!kelly From: kelly@nmtsun.nmt.edu (Sean Kelly) Newsgroups: comp.lang.c Subject: Another silly question Message-ID: <2459@nmtsun.nmt.edu> Date: 26 Apr 89 22:57:40 GMT References: pointer array reference access element Reply-To: kelly@titan.nmt.edu (Sean Kelly) Organization: New Mexico Tech, Socorro NM Lines: 32 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@nmtsun.nmt.edu --The Prisoner --