Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!apple!oliveb!pyramid!ctnews!mitisft!kemnitz From: kemnitz@mitisft.Convergent.COM (Gregory Kemnitz) Newsgroups: comp.lang.c Subject: Re: Is this portable? Summary: If the machine's C compiler accepts K&R, it should work Message-ID: <683@mitisft.Convergent.COM> Date: 10 May 89 02:24:20 GMT References: <1914@plx.UUCP> Organization: Convergent Technologies, San Jose, CA Lines: 27 In article <1914@plx.UUCP>, evan@plx.UUCP (Evan Bigall) writes: . This works on my machine, but I am curious as to whether it is "officially" . correct and portable C. I can think of some machines where it could be trouble . . main() . { int array[10], *ptr, j; . . for(j=0; j<10; j++) . array[j]=j; . . ptr= &array[1]; . . for(j= -1; j<9; j++) . printf("%d\n", ptr[j]); . } . From page 94 of K&R: If pa points to a particular element of an array a, then by definition pa+1 points to the next element, and in general pa-i points i elements before pa and pa+i points i elements after. (end of quote). Greg Kemnitz