Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!panda!genrad!decvax!wanginst!ulowell!walton From: walton@ametek.UUCP (Steve Walton) Newsgroups: comp.sys.amiga Subject: argv[n][n] doesn't exist Message-ID: <816@ulowell.UUCP> Date: Thu, 4-Dec-86 11:59:46 EST Article-I.D.: ulowell.816 Posted: Thu Dec 4 11:59:46 1986 Date-Received: Fri, 5-Dec-86 06:08:05 EST Sender: page@ulowell.UUCP Lines: 24 Bill Mayhew says (and others commiserate): > I just ran into a minor annoyance with the Lattice C compiler >that we have here at work. If memory stikes me right, it's version >3.02. > >I discovered that when I read argv[n][n] that the string isn't always >terminated with a \0 as you'd expect. This seems to happen mostly (if >not only) when the string contains ascii characters that are digits. 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. Stephen Walton ARPA: ametek!walton@csvax.caltech.edu Ametek Computer Research Div. BITNET: walton@caltech 610 N. Santa Anita Ave. UUCP: ...!ucbvax!sun!megatest!ametek!walton Arcadia, CA 91006 USA 818-445-6811