Mail Archives: djgpp-workers/1997/11/06/12:00:02
>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 -