Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!rutgers!clyde!cbatt!neoucom!wtm From: wtm@neoucom.UUCP (Bill Mayhew) Newsgroups: comp.sys.amiga Subject: Garbage in argv[] w/Lattice C Message-ID: <329@neoucom.UUCP> Date: Sat, 29-Nov-86 17:18:12 EST Article-I.D.: neoucom.329 Posted: Sat Nov 29 17:18:12 1986 Date-Received: Sat, 29-Nov-86 21:10:42 EST Organization: Northeastern Ohio Universities College of Medicine Lines: 41 Keywords: Annoyance Hi people, 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. Strings in argv[] that have digits in them seem to be terinated with 0xff ( ) some of the time, other times \0 as you'd expect. I never noticed the effect until one of our poeple started using file names containing digits (which we read from argv[]), and it took a while before we hit one. What I was doing was parsing the string until I hit the zero at the end, so I was getting an extra character or two of junk tacked on to the end of what appeared to be the legitimate file name. For the momenet. I'm going to assume that in this specialized case that either 0x00 or 0xff can be a valid string terminator. Is there a better way to do it? If what I described is a real bug rather than my imagination, is it an artifact of something that CLI does while scanning the command line before passing off to my program, or is LCstartup goofing it up? My apologies if this discussion went around before, but I didn't notice it. --Bill Bill Mayhew Divsion of Basic Medical Sciences Northeastern Ohio Universities' College of Medicine Rootstown, OH 44272 USA phone: 216-325-2511 (...!cbatt!neoucom!wtm would be a good path)