Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!cme!durer!rowe From: rowe@cme.nist.gov (Walter Rowe) Newsgroups: comp.lang.c Subject: Re: C question -- pointer to array of characters Message-ID: Date: 18 Oct 89 15:50:41 GMT References: <6569@ficc.uu.net> Sender: news@cme.nbs.gov Distribution: usa Organization: National Institute of Standards and Technology Lines: 33 In-reply-to: kunkee@ficc.uu.net's message of 17 Oct 89 22:37:59 GMT >>>> On 17 Oct 89 22:37:59 GMT, kunkee@ficc.uu.net (randy kunkee XNX MGR) said: kunkee> main() kunkee> { kunkee> char (*foo)[]; kunkee> char bar[20]; kunkee> kunkee> foo = bar; kunkee> } (1) `bar' is an array of characters (2) `foo' is a pointer to an array of characters, meaning that it's supposed to hold the array's address. So, `foo' should hold the address of `bar'. (3) The value of `bar' is the address of the first character in the array. The value of `&bar' is the address of the array `bar'. The proper assignment, as you already know from other postings, is; foo = &bar; Now `foo' contains the address of the array `bar'. The compiler was right to complain about this since you weren't using `foo' in the manner that you declared it. Others made that point clear, however, no one explained the reason why. This is not a flame, just trying to help you understand how things are interpreted. Walter -- This is just my opinion ...