Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: external declarations of ptrs and arrays Message-ID: <364@taumet.com> Date: 31 Jul 90 16:19:48 GMT References: <674@dg.dg.com> Organization: Taumetric Corporation, San Diego Lines: 24 hmelman@absolut.rtp.dg.com (Howard Melman) writes: >I have the file declare.c: >char temp[20]="blah"; >I have the file use.c: >extern char *temp; >This causes a core dump. As well it should. This is, I believe, in the Frequently Asked Questions list, or should be. The declarations "pointer-to" and "array-of" are NOT equivalent types. There are some expression contexts where either type may be used with the same semantics. "char *temp[20];" means "temp is the first address of an array of 20 chars". "temp[n]" means "n bytes past temp". "char *temp;" means "temp is a pointer variable which contains the address of a char". "temp[n]" means "n bytes past *temp". -- Steve Clamage, TauMetric Corp, steve@taumet.com