Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!ucsd!sdcsvax!ucsdhub!isg100!nusdhub!rwhite From: rwhite@nusdhub.UUCP (Robert C. White Jr.) Newsgroups: comp.lang.c Subject: Re: When is a cast not a cast? Message-ID: <1332@nusdhub.UUCP> Date: 3 May 89 22:02:10 GMT References: <2747@buengc.BU.EDU> Organization: National University, San Diego Lines: 22 in article <2747@buengc.BU.EDU>, bph@buengc.BU.EDU (Blair P. Houghton) says: [p and c are of type (char *)] > 10 p = (c + (char *) i); /* More trouble than it's worth... */ and totally inaccurate too boot. The + operator is defined separately for the addition of a pointer-to-type and and interger. The specs indicate that you will get the operation p=c+(i*sizeof_typeof_c) so the cast is in error. pointer + interger is legal. if you had an array of structures anmed "strarray" and you set a pointer to the Nth entry, and you wanted to get to the N+Mth entry the following code is legal and correct: structure somestruct strarry[1000], *ptr; ptr = strarry[N]; ... ptr = ptr + M; /* or ptr += M */ ... [Unless, of course, I am brain dammaged and therefore not correct in interpreting this stuff] Rob.