From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: char **argv vs. char *argv[] Date: Wed, 11 Jun 1997 08:27:18 -0700 Organization: Alcyone Systems Lines: 35 Message-ID: <339EC3D6.6B9A09B9@alcyone.com> References: <5ndap9$mgd AT freenet-news DOT carleton DOT ca> <339A96E3 DOT 775FA388 AT intercity DOT it> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Andrea Glorioso wrote: > I guess they mean exactly the same, because declaring a variable int a[] > is pretty equal to declaring int ** a. Be careful about this; pointers and arrays are _not_ the same. They can be manipulated in a few different ways, but they are _not_ identical. > I've seen char * argv[] and > char** argv being used many times without problems. I think they are > also compiled in the same way, but maybe you should try to compile to > assembly code to figure it out. . . . except in the case of function arguments. A function with an argument of a single-dimensioned array is treated in all ways identically to a pointer. That is, a function with prototype f(int ai[]); is treated precisely the same as one with prototype f(int *ai); Since main is just another function, this applies to it as well. Either char **argv (pointer to pointer to char) or char *argv[] (array of pointer to char) are both treated the same, and so both are legal. (Note that char (*argv)[], or pointer to array of char, would be illegal.) -- Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com Alcyone Systems / web / http://www.alcyone.com/max/ San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W \ "Covenants without the sword / are but words." / Camden