Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: Contents of argv[0] Keywords: start-up code, argv specifications Message-ID: <1017@virtech.UUCP> Date: 15 Aug 89 11:55:39 GMT References: <9002@attctc.Dallas.TX.US> Organization: Virtual Technologies Inc Lines: 13 In article <9002@attctc.Dallas.TX.US>, jls@attctc.Dallas.TX.US (Jerome Schneider) writes: > Both K&R and H&S document the argv[0] string as "the name of the program". > This definition doesn't seem to mandate (or exclude) the presence of a path > component in the string. A few *nix programs use rindex() or strrchr() to > scan for '/', implying (to me at least) that _some_ implementations consider > "name" to include such information. On most, if not all, unix systems argv[0] will contain the path used to execute the program (i.e. the first argument to an execl()). This may be a relative path, a full path and/or a simple name. Your code should handle all cases. (this would also make it portable to other systems that do not pass in the path). On some older versions of Microsoft C, argv[0] was always empty (i.e. char * 0) because that information was not available from DOS.