1.3.2 Program Startup

A program begins by calling the function main. There is no prototype required for this. It can be defined with no parameters such as:

int main(void) { body… }

Or with the following two parameters:

int main(int argc, char *argv[]) { body… }

Note that they do not have to be called argc or argv, but this is the common naming system.

argc is a nonnegative integer. If argc is greater than zero, then the string pointed to by argv[0] is the name of the program. If argc is greater than one, then the strings pointed to by argv[1] through argv[argc-1] are the parameters passed to the program by the system.



int main(int argc, char *argv[])
  int loop;

    printf("My program name is %s.\n",argv[0]);

      printf("Parameter #%i is %s.\n",loop,argv[loop]);