/**
* the arguments passed to main function
*
* argc(conventionally called, argument count):
* the number of command-line arguments the program was invoked with
* argv(conventionally called, argument vector):
* a pointer to an array of character strings that contain the arguments,
* one per sting
* envp(conventionally called, environment pointer):
* points to a null-terminated array of pointers to char, each of which points
* to a string that provides information about the environment for this execution
* of the program
*/
#include <stdio.h>
int main(int argc,char *argv[],char *envp[])
{
int i;
printf("These are the %d command-line argument%s passed to main:\n",
argc, (i > 1) ? "s":"");
for(i = 0; i < argc; i++)
printf(" argv[%2d]: %s\n", i, argv[i]);
printf("\nThe environment string(s) on this system are:\n");
for(i = 0; envp[i]; i++)
printf( " envp[%2d]: %s\n", i, envp[i]);
return 0;
}
传递给main函数的三个参数
最新推荐文章于 2023-01-29 17:33:29 发布