Re: What does "*" mean in "int main(int argc, char *argv[])"?

From: Tom (tvaus_at_sympatico.ca)
Date: 02/13/05


Date: Sun, 13 Feb 2005 06:01:43 -0500

argc - is the number of parameters in the command line including
the program name.
argv[] - is the array of parameters passed in the command line.

As JoeC said, it is a pointer to an array of type char.
You can use argc in a for loop to process the argv[] values.

The int main simply means that the program will return an int after
execution. Using 'void main . . .' will work as well, you just don't
have to return a value. (not good if you want to use your program
in a batch file and need to check the error level for taking care of
the problem the program encountered)

Tom.

"JoeC" <enki034@yahoo.com> wrote in message
news:1108189249.089913.46440@z14g2000cwz.googlegroups.com...
> Sorry,
>
> the * means pointer. That ponts to first character in each word that
> you enter from the cmd line.
>
> For example you could write a porgram Hello.
>
> You can run the program with Hello Bob and it will take that value and
> display it in your porgam.
>



Relevant Pages

  • array element count (was: Re: problem with whitespace not splitting on split. -SOLVED - with
    ... #$arrayname that has the count of array elements. ... @ARGV The array @ARGV contains the command-line arguments intended ... See $0 for the command name. ... assignment to $[can be seen from outer lexical scopes ...
    (perl.beginners)
  • Re: Type of argc
    ... object is defined so that the size of an array is obtained by multiplying ... How is main(size_t argc, char **argv) different? ... the argv array, argv need one more element for the final NULL. ...
    (comp.std.c)
  • Re: Finding lines with a common beginning
    ... then it is a matter of copying each ARGV[1] ... through ARG[ARGC - 1] to a local array, ... reset the print flag and quit printing. ...
    (comp.lang.awk)
  • Re: Is argv array modifiable ?
    ... This is unfortunate because using the UNIX ps command you can see the arguments, and the client is security concious. ... To each element of the array I allocated memory and copied the string, ... I then went through the original array an null terminated each string pointed to by argv with the exception of argv. ...
    (comp.lang.c)
  • Re: CLIL source code from book "Firmware demystified"
    ... > I don't quite understand WHY I can pass 'argc' and 'argv' to another ... The reason I ask this is every command I type in command line is ... In particular, what do you mean by "single-running processes, not as ...
    (comp.arch.embedded)