Contents of argv[0]

Alan J Rosenthal flaps at dgp.toronto.edu
Sat Aug 19 03:07:11 AEST 1989


peter at ficc.uu.net (Peter da Silva) writes:
>	parse_file(name, buffer)
>	char *name;
>	struct filename *buffer;
>
>		Parses the elements of name into the buffer. name will
>		be modified as necessary to null-terminate the elements
>		of buffer. Returns the actual number of elements found
>		in the name... missing or meaningless elements will contain
>		null pointers.

Problem is, there aren't always characters available in the right places in
name to be overwritten with zeroes to terminate the various strings.  In unix,
consider the file name "/file".  The directory is "/", the file name is "file",
but there's nowhere to put the zero to terminate the string "/".  A directory
name of "" is not acceptable; it will work under some circumstances (namely,
when a slash and a file name is appended) but not in all.

ajr



More information about the Comp.lang.c mailing list