extern char *foo vs. extern char foo[]

Karl Heuer karl at haddock.ima.isc.com
Fri Jun 8 11:26:09 AEST 1990


In article <586 at isi.UUCP> mark at isi.UUCP (Mark Bailey) writes:
>It is the declarations:
>     char     foo[];  and
>     char     *foo;
>which are identical.  (K&R 1, p. 95)

This is true *only* for the declaration of a pointer as a formal parameter,
as the K&R quote says.

>The reference manual appears to allow such a declaration which is not
>used as a formal parameter (K&R 1, p. 194).

Yes, but then they're no longer identical.  In this context `char foo[];'
declares an array (and it had better be an extern if you're leaving out the
size), while `char *foo' declares a pointer.  See the FAQ list.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list