Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!oliveb!bene!itkin From: itkin@bene.UUCP (Steven List) Newsgroups: comp.lang.c Subject: Re: Destroying arguments Message-ID: <485@bene.UUCP> Date: Sun, 17-May-87 14:29:19 EDT Article-I.D.: bene.485 Posted: Sun May 17 14:29:19 1987 Date-Received: Sun, 17-May-87 20:02:45 EDT References: <292@osupyr.UUCP> <239@polyof.UUCP> Reply-To: itkin@bene.UUCP (super-user) Distribution: comp.unix.questions Organization: Benetics Corporation, Mt. View, CA Lines: 17 In article <239@polyof.UUCP> john@polyof.UUCP ( John Buck ) writes: >In article <292@osupyr.UUCP>, dusan@osupyr.UUCP (Dusan Nedeljkovic) writes: >> I'm looking for a way to modify/destroy agruments passed to a C program >> on the command line. >For each argv[] element you wish to destroy, simply copy another (any) >string (or string of characters) over it using strncpy() or a pointer >assignment loop: Without commenting in detail on John's reply, I would note that since argv is an array of POINTERS to strings, the simple thing to do is to set up your own string and then store the address/pointer in argv[n]. This avoids the potential pitfalls that John's method involves and gives you the option to store ANYTHING YOU WANT in the argument list. I'm curious as to WHY you want to modify/destroy command line arguments? Another note - if you want to remove a command line argument (so it won't show up in a ps for instance), you can just copy pointers up in the array.