external declarations of ptrs and arrays

Howard Melman hmelman at absolut.rtp.dg.com
Sat Jul 28 00:36:03 AEST 1990


I'm having some problems with an external declaration of a character
array.  I have some vague ideas why, but rather than guessing I'd rather
get some definitive answer from someone.  Here goes:

I have the file declare.c:

char temp[20]="blah";

I have the file use.c:

#include <string.h>
extern char *temp;
main()
{
	return(strcmp(temp,"blah");
}

This causes a core dump.  When I change my extern declaration in use.c to be:

extern char temp[];

the program works fine.  I was under the impression that the two
declarations were the same.  Help...

Howard



More information about the Comp.lang.c mailing list