Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mephisto!udel!freezer!gdtltr From: gdtltr@freezer.it.udel.edu (Gary Duzan) Newsgroups: comp.unix.questions Subject: NULL as a string terminator (was Re: Get process name... ) Message-ID: <26593@nigel.ee.udel.edu> Date: 4 Aug 90 06:15:40 GMT References: <9220003@hpldsla.sid.hp.com> <707@mtune.ATT.COM> Sender: usenet@ee.udel.edu Reply-To: gdtltr@freezer.it.udel.edu (Gary Duzan) Organization: Brain Dead Innovations (BDI) Lines: 28 Nntp-Posting-Host: maplenut.it.udel.edu In article <707@mtune.ATT.COM> jrw@mtune.ATT.COM (Jim Webb) writes: => => char psbuf[64]; => char command[15]; => FILE *ps; => => /* I'm sure this could be done better in perl :-) */ => sprintf(psbuf,"ps -p%d|awk '{/PID/ {next} { print $4 }'",getpid()); => ps=popen(psbuf,"r"); => fgets(command,15,ps); => pclose(ps); => command[strlen(command)-1]=NULL; /* chop off the \n */ ^^^^ Pardon me for reopening the NULL discussion, but won't this give a warning if NULL is #defined (void *) 0? If it doesn't, should it? Assigning a pointer to a char is certainly a questionable thing to do. Gary Duzan Time Lord Third Regeneration -- gdtltr@freezer.it.udel.edu _o_ -------------------------- _o_ [|o o|] If you can square, round, or cube a number, why not sphere it? [|o o|] |_O_| "Don't listen to me; I never do." -- Doctor Who |_O_|