Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!shadooby!accuvax.nwu.edu!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: C problems Message-ID: <17933@mimsy.UUCP> Date: 7 Jun 89 04:47:56 GMT References: <29@ <236100015@mirror> <13566@haddock.ima.isc.com> <8639@chinet.chi.il.us> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 38 >In article <13566@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) >writes: >>... since this use of [] is a special case which exists nowhere >>else in the language (it works *only* for formal arguments), it may be >>less confusing to stick with "char **argv" after all. In article <8639@chinet.chi.il.us> les@chinet.chi.il.us (Leslie Mikesell) writes: >Umm, isn't that the same as: > >char *list[] = { "one", "two", "three", 0 }; > >which seems to work as a global definition. No, it is not the same---it only looks the same to the casual observer. As Karl stated, `char *argv[]' is a special case because argv is a formal parameter. A C compiler is required silently to pretend that you actually wrote `char **argv'. That is: char *list[] = { 0, "hello", 0 }; void foo() { (void) main(2, list); } int main(int argc, char *argv[]) { if (argc > 1) puts(argv[1]); else foo(); return 0; } is treated by the compiler as though argv (and only argv) were declared with int main(int argc, char **argv) { The declaration for `list' is *not* altered, because it is not a formal parameter. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris