1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

main (int argc, char* argv[], char* envp[]) {


}

  • argc is the number of parameters passed to the
    program, rememberthat the program name is counted as
    one of the parameters
  • argv is an array of string pointers, there is one entry
    in this array for each parameter to the program, the
    parameters to a program are separated by white space,
    unless they are enclosed in quotes (" or ')
  • For example


prog -x -f fred george


will produce the following:


argc = 5
argv[0] = "prog"
argv[1] = "-x"
argv[2] = "-f"
argv[3] = "fred"
argv[4] = "george"
argv[5] = NULL;

  • *envp is an array of pointers to strings, each string
    contains the value of one of the environment variables, the
    end of the envp array is marked by a zero entry
  • *Each entry in the envp array has the following format

    March 3, 1998Page 10C201/TAM