Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site hadron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!rlgvax!prcrs!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: Pointer confusion -- forgot original title Message-ID: <131@hadron.UUCP> Date: Tue, 12-Mar-85 20:46:29 EST Article-I.D.: hadron.131 Posted: Tue Mar 12 20:46:29 1985 Date-Received: Fri, 15-Mar-85 00:12:25 EST References: <104@azure.UUCP> <677@ukma.UUCP> <11807\*gatech.UUCP> Organization: Hadron, Inc., Fairfax, VA Lines: 21 > It has been my understanding, that in USE "*ptr[]" and "**ptr" are > essentially the same and can be used interchangably. > However, at initialization you have to declare the size of the array > as David says above. The reason that you can get away with > "char *argv[]", is because the number of arguments that is passed > to the program environment is know.(in argc) Am I wrong? This subject has been thouroughly thrashed to death. If this gets back to you and you haven't seen an incredibly long article on the subject, send mail and I will re-post it. Basically, yes, you are wrong. An array of X's declares multiple contiguous units of storage for objects of type X. A pointer to X declares one pointer-unit of storage in a form that can point to an object of type X. There are a number of reasons that this distinction is important, primarily that a pointer is an lvalue and must be initialised (passing an argument counts), while an array can never be an lvalue. The only place that the two are really identical is as an argument to a function. This is because, for historical reasons (see previous article), a declaration of an array argument to a function is IMPOSSIBLE, so when you declare an array, C says, "oh, he really meant a pointer." Your argument w i l l always be a pointer -- an array never really gets passed.