Topic: Void main() -- 4 Parameters to `main
Author: JdeBP@jba.co.uk (Jonathan de Boyne Pollard)
Date: 1995/06/06 Raw View
A fourth quibble with [basic.start.main] :
The wording for `argc' and `argv' is also a bit loose. It implies that
`argv[0]' contains both a parameter *and* the program name (or ""). This
in turns implies the somewhat perverse notion that the program name is
itself an argument (which is certainly not a notion used by any of the
operating systems or command shells that I know).
Better to say that where argc is greater than 1, argv[1] through
argv[argc-1] contain the arguments.
It also implies that argc can be zero, and leaves that case undefined. It
is reasonable to assume that an implementation can supply "" for argv[0]
even if it does not support notions of program arguments and program name,
therefore it is daft to leave a loophole such as this. This is especially
so since whatever notions the implementation *does* support are better
handled by the implementation defining an additional (and more appropriate)
alternate definition for main, such as (for example)
int main (unsigned long instance_handle) ;
Better to say that `argc' must be nonnegative and nonzero.