Mail Archives: djgpp/1998/04/20/09:13:34
Message-Id: | <199804201307.QAA18448@ankara.duzen.com.tr>
|
From: | "S. M. Halloran" <mitch AT duzen DOT com DOT tr>
|
Organization: | User RFC 822- and 1123-compliant
|
To: | djgpp AT delorie DOT com
|
Date: | Mon, 20 Apr 1998 16:12:23 +0200
|
MIME-Version: | 1.0
|
Subject: | Re: Separators wrong in argv[0] ?
|
In-reply-to: | <353B0E64.2FDA4E81@hp.com>
|
On 20 Apr 98 Andrew McLean was found to have commented thusly:
> When I look at 'argv[0]', I expect to see the fully-qualified filename
> of my executable. I do, but the separators are Unix-style
> '/' instead of DOS-style '\'.
> Is there a switch to correct this ?
Try this code fragment/function (untested!):
--------
void utodpath(str)
char *str;
{
do
if (*str == '/')
*str = '\';
while (*str++ != '\0');
return;
}
--------
You would then call the function using something like utod(argv[0]).
It might be better to duplicate the string--strdup(), or strcpy() to a
local char array or pointer from the heap--then modify the copy the way
you want rather than directly change any characters in the arguments
delivered to main(), for reasons that I cannot think of right now, other
than "being on the safe side." You should be able to do whatever you want
with a copy of any string.
Why do you want to do the conversion by the way?
Mitch Halloran
Research (Bio)chemist
Duzen Laboratories Group
Ankara TURKEY
mitch AT duzen DOT com DOT tr
other job title: Sequoia's (dob 12-20-95) daddy
- Raw text -