More on pointers/arrays: Function Arguments

jbf at ccieng5.UUCP jbf at ccieng5.UUCP
Thu Apr 12 08:12:03 AEST 1984


>    char *index (s, c)
>	char s [], c;
>    {
>	while (*s != '\0' && *s != c)
>	    ++s;				/* AARGH!! */
>	return (*s == c ? s : NULL);
>    }
>
>This passes through Berkeley CC and LINT unscathed, and compiles.
>Yet K&R Appendix A Section 14.3 Sentence 2 (sound biblical?) says
>"...arrays are not lvalues" and Section 7.2 clearly states
>autoincrement as "++ lvalue".  Hmmm ...

The argument s is actually a string pointer rather than an array.  In
K&R's reference manual Section 10.1 "External Function Definition", it
states in the penultimate sentence of the last paragraph that
"declarations of formal parameters declared 'array of' are adjusted to
read 'pointer to..' ".

Azhrarn
-- 
Reachable as
	....allegra![rayssd,rlgvax]!ccieng5!jbf



More information about the Comp.lang.c mailing list