Re: Difference between argc and argv?
From: Greg Comeau (comeau_at_panix.com)
Date: 03/01/04
- Next message: PHP2: "Re: C++ ebooks/books on the web?"
- Previous message: Karl Heinz Buchegger: "Re: Difference between argc and argv?"
- In reply to: Gawnsoft: "Difference between argc and argv?"
- Next in thread: Francis Glassborow: "Re: Difference between argc and argv?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Mar 2004 09:20:40 -0500
In article <icf640l5k0g7g85k1sctkh2udukiilf8s9@4ax.com>,
Gawnsoft <xlucid@users.sourceforge.remove.this.antispam.net> wrote:
>On Sat, 28 Feb 2004 20:09:58 GMT, "Mike Wahler"
><mkwahler@mkwahler.net> wrote (more or less):
>>[main()s] paramters, typically named
>>'argc' and 'argv'...specify the number of arguments passed, and
>>a pointer to an array of strings representing the actual
>>arguments.....
>
>What's the difference between argc and argv?
Here's what Standard C says:
"... two parameters (referred to here as argc and argv, though
any names may be used, as they are local to the function in which
they are declared):
int main(int argc, char *argv[]) { /* ... */ }
or equivalent;9) or in some other implementation-defined manner.
If they are declared, the parameters to the main function shall
obey the following constraints:
* The value of argc shall be nonnegative.
* argv[argc] shall be a null pointer.
* If the value of argc is greater than zero, the array members
argv[0] through argv[argc-1] inclusive shall contain pointers
to strings, which are given implementation-defined values by the
host environment prior to program startup. The intent is to
supply to the program information determined prior to
program startup from elsewhere in the hosted environment.
If the host environment is not capable of supplying strings with
letters in both uppercase and lowercase, the implementation
shall ensure that the strings are received in lowercase.
* If the value of argc is greater than zero, the string pointed to
by argv[0] represents the program name; argv[0][0] shall be
the null character if the program name is not available from the
host environment. If the value of argc is greater than one,
the strings pointed to by argv[1] through argv[argc-1]
represent the program parameters.
* The parameters argc and argv and the strings pointed to by the
argv array shall be modifiable by the program, and retain their
last-stored values between program startup and program termination."
Feel free to post any questions about the above.
-- Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
- Next message: PHP2: "Re: C++ ebooks/books on the web?"
- Previous message: Karl Heinz Buchegger: "Re: Difference between argc and argv?"
- In reply to: Gawnsoft: "Difference between argc and argv?"
- Next in thread: Francis Glassborow: "Re: Difference between argc and argv?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|