Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles; site uiuccsb.UUCP Path: utzoo!linus!vaxine!wjh12!genrad!decvax!harpo!ulysses!burl!we13!ihnp4!inuxc!pur-ee!uiucdcs!uiuccsb!eich From: eich@uiuccsb.UUCP Newsgroups: net.lang.c Subject: Re: More on pointers/arrays: Function A - (nf€Þ Message-ID: <9000021@uiuccsb.UUCP> Date: Fri, 13-Apr-84 15:09:00 EST Article-I.D.: uiuccsb.9000021 Posted: Fri Apr 13 15:09:00 1984 Date-Received: Sun, 15-Apr-84 01:54:53 EST References: <215@harvard.UUCP> Lines: 19 Nf-ID: #R:harvard:-21500:uiuccsb:9000021:000:622 Nf-From: uiuccsb!eich Apr 13 14:09:00 1984 #R:harvard:-21500:uiuccsb:9000021:000:622 uiuccsb!eich Apr 13 14:09:00 1984 /**** uiuccsb:net.lang.c / harvard!brownell / 10:57 pm Apr 10, 1984 ****/ char *index (s, c) char s [], c; { while (*s != '\0' && *s != c) ++s; /* AARGH!! */ return (*s == c ? s : NULL); } /* ---------- */ Nothing wrong with this, except that it can cause array-as-lvalue confusion: s is not an array. Because of C's call-by-value semantics, an array name used as an actual parameter (or equivalently, used in an expression) is converted to a pointer to the first element of that array. Lax (actually, generalized) syntax for formal argument declaration allows [] to be used where * is correct.