pointer question
Archie Lachner
archiel at hercules.UUCP
Sat Apr 7 08:00:49 AEST 1984
As I read Kernighan and Ritchie (K & R), the assertion that the statement
p = p + 4;
where p is a pointer, is dangerous and non-portable is completely wrong.
In section 5.4, p. 98, it is stated that when an int or constant is
added to a pointer, it is first scaled by the size of the object the pointer
points to. For example, and I am quoting directly now,
"The construction
p + n
means the n-th object beyond the one p currently points to."
As far as I am concerned, K & R contains the definition of the C language.
Expressions such as "p + 4" above are not dangerous and completely portable,
at least to machines and systems where the C compiler implements the language
correctly.
--
Archie Lachner
Logic Design Systems Division
Tektronix, Inc.
uucp: {ucbvax,decvax,pur-ee,cbosg,ihnss}!tektronix!teklds!archiel
CSnet: archiel at tek
ARPAnet: archiel.tek at rand-relay
More information about the Comp.lang.c
mailing list