Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!ames!ucbcad!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: argv[n][n] doesn't exist. Buls@#$ of course it exists! Message-ID: <8612051913.AA02928@cory.Berkeley.EDU> Date: Fri, 5-Dec-86 14:13:56 EST Article-I.D.: cory.8612051913.AA02928 Posted: Fri Dec 5 14:13:56 1986 Date-Received: Fri, 5-Dec-86 21:30:31 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: University of California at Berkeley Lines: 32 Sorry, argv[] CAN be addressed with a double array subscript. The first subscript accesses the particular char * pointer, the second accesses the particular character in that pointer. The following are equivalent: char **argv; char *argv[]; ------------------------------------------------------------------ argv[i] -returns char *, a pointer to argument i argv[i][0] -returns a char, the first character in argument i argv[i][n] - etc... As to the original problem: Did anyone think to check if the string returned by argv[i] ended in \0? If so, then the problem is with Lattice... generating bad code. Otherwise, the problem is with the startup module. I wasn't tracking the discussion, so I may be way off track here. -Matt Your message: >From: walton@ametek.UUCP (Steve Walton) >Ahem...argv is not a two dimensional array, but rather an array of pointers. >As such, it CANNOT be addressed with two subscripts as argv[n][n]. There >is a difference, see K&R for details. The correct way to find the \0 at >the end of the j'th argument is: > char *s; > s = argv[j]; > for (i = 0; s[i] != '\0'; i++); /* i is now length of arg j */ >If I badly misunderstood Bill's posting and have therefore insulted >everyone's intelligence, forgive me.