Path: utzoo!attcan!uunet!iconsys!bryan From: bryan@iconsys (Bryan Cardoza) Newsgroups: comp.lang.c Subject: Re: external declarations of ptrs and arrays Message-ID: <61@iconsys> Date: 31 Jul 90 16:48:06 GMT References: <674@dg.dg.com> Organization: SANYO/ICON, Orem, Utah Lines: 35 In article <674@dg.dg.com> 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. 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... No so. When using *temp, the contents of temp are used, whereas when using temp[], the address of temp is used. In M68k assembly (using the System V/68 assembler syntax) we are talking about the difference between mov.l temp,%a0 for *temp and mov.l &temp,%a0 for temp[]. Sure, you can often use the two the same way in your C programs, but remember, we're talking about a storage declaration here, and pointers and arrays are not the same thing. -- Bryan Cardoza UUCP: uunet!iconsys!bryan Software Engineer Internet: bryan@iconsys.icon.com Icon International, Inc. (801) 225-6888 Orem, Utah FAX: (801) 226-0651