extern declaration inconsistency

Andrew Koenig ark at rabbit.UUCP
Thu Apr 5 02:09:20 AEST 1984


If, in one file, you say

	char ch[32];

and in another file, you say

	char *ch;

then your program won't work.  Reason:  in the first file you have
asked for memory to be associated with the external name "ch" that
should contain a 32-character array, and in the second you have asked
for the same memory to be associated with a character pointer.  In
those implementations which I am familiar, the first four (or two)
characters in the array will be interpreted as the address pointed to
by the pointer.

Arrays and pointers are simply different, though they can be used
interchangably in a few contexts.



More information about the Comp.lang.c mailing list