Re: int main (int argc, char **argv)

From: Pete C. (x_at_x.x)
Date: 06/17/04


Date: Thu, 17 Jun 2004 20:21:53 GMT

Frane Roje wrote:
> I just wanted to say that the first element of argv is the path of the
> executable.

Yes, here is what the standard has to say about it:

"
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[argc-1] as
pointers to the initial characters of null-terminated 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. ]
"

- Pete



Relevant Pages

  • Re: starting into H&S
    ... pointers. ... If argc is 3, and argv is null, he's not using a conforming ... There is an extra level of indirection here. ...
    (comp.lang.c)
  • Re: No more Foxpro
    ... your mainfunction gives you to paramters. ... The second, argv[] is an array ... of string pointers that point to the various paramters. ... I'd love to have an argc and argv. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Basic: obtain file path of .exe
    ... Then it was almost not an off topic question. ... In the latter form argc shall be the number of arguments passed ... through argvas pointers to the initial characters of ...
    (comp.lang.cpp)
  • Re: No more Foxpro
    ... I guess with argv[] you mean feeding an unlimited number of parameters to a function, ... I'd love to have an argc and argv. ... pointers could be stored in a database field while the thing that they ... I'm not sure what we would gain from storing pointers in a database. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Type of argc
    ... Jack Klein wrote: ... The size of argv is argc * sizeofbytes. ... And for argv, there is an implicit second value which is sizeof. ... "Consideration shall be given to the need for as many as 32 characters ...
    (comp.std.c)