|
From: Ioannis V. <no...@ho...> - 2002-06-19 20:48:38
|
Yes, if the mechanism work. There is a possibility the program to not
"see" the arguments and argc to be 0. Also if it works, argv[0] can be
"" (which is '\0' and 0).
The C++ standard says:
"An implementation shall not predefine the main function. This function
shall not be overloaded. It shall
have a return type of type int, but otherwise its type is
implementationdefined.
All implementations
shall allow both of the following definitions of main:
int main() { /* ... */ }
and
int main(int argc, char* argv[]) { /* ... */ }
In the latter form argc shall be the number of arguments passed to the
program from the environment in
which the program is run. If argc is nonzero these arguments shall be
supplied in argv[0] through
argv[argc1] as pointers to the initial characters of nullterminated
multibyte strings (NTMBSs)
(17.3.2.1.3.2) and argv[0] shall be the pointer to the initial character
of a NTMBS that represents the
name used to invoke the program or "". The value of argc shall be
nonnegative. The value of
argv[argc] shall be 0. [Note: it is recommended that any further
(optional) parameters be added after
argv. ]"
Ioannis
* Ioannis Vranos
* Programming pages: <http://www.noicys.cjb.net>
http://www.noicys.cjb.net
* Alternative URL: <http://run.to/noicys> http://run.to/noicys
> -----Original Message-----
> From: dev...@li...
> [ <mailto:dev...@li...>
mailto:dev...@li...] On Behalf
> Of Mac Reiter
> Sent: Wednesday, June 19, 2002 7:47 PM
> To: C++
> Subject: RE: [Dev-C++] 2 questions
>
>
> I'm a little disturbed by the description given below. I'm
> pretty sure
> that argc includes the name of the executable, so that
> "bot.exe level3.bot"
> would have argc == 2. I know that argv[0] contains the name of the
> executable, because UN*X systems use this to distinguish behaviors for
> symlinked executables (don't ask, it isn't possible on
> Windows, and it is
> slightly odd anyway). The practical upshot is that, for the
> example above,
> argv[0] would be "bot.exe" and argv[1] would be "level3.bot".
|