Difference between "char *arr" and "char arr[]"

Eyal Lebedinsky eyal at echo.canberra.edu.au
Wed Sep 26 08:30:20 AEST 1990


Following the discussion, I feel that two issues are beeing mixed:
1 - an object is either an array OR a pointer with no ambiguity.
2 - a reference to an object can mix array/pointer notation.

If an object is declared/defined so as to lead the compiler to see it as an
array then all references will follow this notion, same with pointer.
So: a[4] can be used to refer to 'a' (regardless if 'a' is arr/point) and the
appropriate code will be emitted depending on THE TYPE of a. '*(a+4)' will do
the same. The C syntax/semantics defines this clearly.
-- 
Regards
	Eyal



More information about the Comp.lang.c mailing list