More on pointers/arrays: Function Arguments

Dave Brownell brownell at harvard.UUCP
Wed Apr 11 01:18:38 AEST 1984


I saw this gem in a recent book on C programming by Thomas Plum,
"Learning to Program in C".  (It's much more tutorial than K&R;
I'm told it's very understandable, but my only exposure to it
is answering a few questions.)

    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 ...


	Dave Brownell
	{genrad|allegra|ihnp4|ima|amd70}!wjh12!sequoia!brownell



More information about the Comp.lang.c mailing list