www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/11/06/12:00:02

Message-Id: <3.0.1.32.19971106105708.007dd210@yacker.xiotech.com>
Date: Thu, 06 Nov 1997 10:57:08 -0600
To: eliz AT is DOT elta DOT co DOT il
From: Randy Maas <randym AT xiotech DOT com>
Subject: Re: 971009 djsplit & djmerge
Cc: Vik DOT Heyndrickx AT rug DOT ac DOT be, djgpp-workers AT delorie DOT com
Mime-Version: 1.0

>On Thu, 6 Nov 1997, Vik Heyndrickx wrote:
> fprintf(stderr,"Usage: %s [inputBase] [outputFile]\n", argv[0]);
>
>The downside of this is that you (usually) get in argv[0] the whole path
name of the program, which might be quite long. 

maybe, in a not so elegant fashion, this would do a decent job:

char *last_sep = strrchr(argv[0], '/');
if (last_sep && last_sep[0]) 
   last_sep++; /* skip past the slash */
 else
   last_sep=argv[0]; /* it wasn't the whole path */

fprintf(stderr,"Usage: %s [inputBase] [outputFile]\n", last_sep);

Of course that can be compacted a lot....

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019