Hi all,
I have an elementary question, of which I never grasped, and i'd like
to finally put it to rest.
I have the following code, which although makes use of the string
library, and could therefore be labelled as OT, the actual question I
have relates to the code around it. This is the highly abridged
version:
const char *fname;
const char *execname="/usr/bin/foo";
char *pathname;
char *str;
....
strcpy(pathname ,execname); <- on my platform
I plan to use strlcpy() :-)
if((str=strrchr (pathname,'/')) != NULL)
{
*++str='\0';
fname=execname+ (str - pathname); <- somehow, fname
ends up being "foo" as intended
} else {
fname=execname;
*pathname='\0';
}
I have checked the ascii values, for the above, and turning the
resulting ascii codes (which seem to be concat'd together), I do not
produce foo.
Would appreciate any help on this, as it's frying my peonic brain!
thanks
KB.
I have an elementary question, of which I never grasped, and i'd like
to finally put it to rest.
I have the following code, which although makes use of the string
library, and could therefore be labelled as OT, the actual question I
have relates to the code around it. This is the highly abridged
version:
const char *fname;
const char *execname="/usr/bin/foo";
char *pathname;
char *str;
....
strcpy(pathname ,execname); <- on my platform
I plan to use strlcpy() :-)
if((str=strrchr (pathname,'/')) != NULL)
{
*++str='\0';
fname=execname+ (str - pathname); <- somehow, fname
ends up being "foo" as intended
} else {
fname=execname;
*pathname='\0';
}
I have checked the ascii values, for the above, and turning the
resulting ascii codes (which seem to be concat'd together), I do not
produce foo.
Would appreciate any help on this, as it's frying my peonic brain!
thanks
KB.
Comment