Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!pasteur!ucbvax!ulysses!cjc From: cjc@ulysses.homer.nj.att.com (Chris Calabrese[rs]) Newsgroups: comp.unix.questions Subject: Re: How does a program get its path name? Message-ID: <10106@ulysses.homer.nj.att.com> Date: 22 Feb 88 16:56:12 GMT References: <11923@brl-adm.ARPA> <2933@sdsu.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 20 Summary: argv[0] In article <2933@sdsu.UUCP>, turtle@sdsu.UUCP writes: > > When a program executes, the full path to the executable file is kept in > the zero-th argument. If you have a declaration of main which looks like this: > main(argc,argv) > int argc; > char *argv[]; > > then argv[0] is a pointer to the full path. > Is this what you were looking for? This is true only if the program was not found in the current working directory, in which case argv[0] will contain only the name of the program, not the full path. Of course, you can test to see if argv[0][0] != '/' and getcwd() to find the full path name. Christopher Calabrese AT&T Bell Laboratories ulysses!cjc