Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!cs.utexas.edu!uunet!crdgw1!sungod!davidsen From: davidsen@sungod.crd.ge.com (ody) Newsgroups: comp.lang.c Subject: Re: Contents of argv[0] Keywords: start-up code, argv specifications Message-ID: <1705@crdgw1.crd.ge.com> Date: 16 Aug 89 14:58:23 GMT References: <9002@attctc.Dallas.TX.US> <1681@crdgw1.crd.ge.com> <2364@wyse.wyse.com> Sender: news@crdgw1.crd.ge.com Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric Corp. R&D, Schenectady, NY Lines: 33 In article <2364@wyse.wyse.com> bob@wyse.UUCP (Bob McGowen Wyse Technology Training) writes: | How about proposing a new function to be called basename(), obviously | coded for the environment which the compiler was running under? It | would return a pointer to a string which would be the name of the | program. This sounds good to me. It is a low effort procedure to write, making it unlikely to be opposed by any vendor on the grounds of execssive cost. It provides a nice standard way to do something which is commonly useful, and at the calling level it is easily specified in a portable way. When do we form the C95 committee? const char *basename(path) const char *path; basename returns a pointer to a static buffer which holds the filename portion of the path pointed to by the path argument. This is a pointer to an internal buffer and the data must be copied if it is to be preserved beyond the next call to basename. Please note: I have formalized bob's excelent suggestion this way because some vendors place the filename in the middle of the path, thus defeating any effort to point to the filename in the original string. Example, a typical VMS filename: CAOVAX::Dra0:[mimsey.bin.special]zoo.exe;4 ^^^^^^^ That's the filename! bill davidsen (davidsen@crdos1.crd.GE.COM) {uunet | philabs}!crdgw1!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me