pointer question

P McFerrin mcferrin at inuxc.UUCP
Fri Apr 6 01:35:28 AEST 1984


A pointer has a length associated with it.  The reason for this is that it
permits such operations as auto-increment/decrement.  If the pointer
is to a char, then an autoincrement operation would bump the pointer
value by 1.  On the other hand, the pointer was to 64 byte complex structure,
an autoincrement operation would increment the pointer value by 64.
The compiler takes care of the boundary allignment problems which will
result in the length of a pointer being adjusted to maintain proper
boundary allignment.

It is dangerous to increment pointer yourself (e.g. p = p + 4).
By doing so, you are restricting your programs to a specific machine type
since wordsize varies among diffenent machines. (a act against portability)

					Paul McFerrin
					AT&T Consumer Products
					...ihnp4!inuxc!mcferrin



More information about the Comp.lang.c mailing list