main(int argc, char *argv[], char *env[])
int argc : the numbers of strings in in command line.
char *argv[] : the array of input srings.
char *env[] : the environment value
In general situation, we just use
main(int argc, char *argv[])
Example:
#include
main(int argc,char *argv[],char *env[])
{
int i;
printf( "These are the %d command-line arguments passed.\n", argc);
for(i=0; i
//printf( "\nThe environment string(s)on this system are: \\n\n ");
//for(i=0; env[i]!=NULL; i++)
//printf( " env[%d]:%s\n ", i, env[i]);
}
output =>>
@matrix:~/oop344> a.out 12 23 34
4 command-line arguments passed.
argv[0]:a.out
argv[1]:12
argv[2]:23
argv[3]:34
没有评论:
发表评论