mixing pointers and arrays

wyse at ihuxp.UUCP wyse at ihuxp.UUCP
Wed Aug 3 05:28:54 AEST 1983


I suggest that you all reread section 5.3 in "The C Programming Language",
by our friends BWK and DMR.  Given that I have

	int a[10];

the reference a[i] is equivalent to *(a+i).  The difference between an array
name and a pointer is that the array name is a constant, i.e., you can't
assign to it.

When a array name is used as an argument to a function, the address of the
beginning of array is passed and as somebody else pointed out, it is
truly a pointer.  However, you can declare it in the function as
either
	char *s;
or
	char s[];
as they are equivalent and which one is used depends on how the expressions
involving s will be written in the function.

		Neal Wyse
		ihnp4!ihuxp!wyse
		Bell Labs, Naperville Ill.



More information about the Comp.lang.c mailing list