I have this program execute with the values 10,20,30 given at command line.
int main(int argc , char **argv)
{
printf("\n Printing the arguments of a program \n");
printf("\n The total number of arguments in the program is %d",argc);
while(argc>=0)
{
printf("%s ",argv[argc]);
argc--;
}
return 0;
}
The outputs is
The total number of arguments in the program is 4(null) 30 20 10 ./a.out
Where did that (null) come from ??
argv[0]is (to the extent possible) supposed to be something that identifies the program being run.argv[1]throughargv[argc-1]are the arguments that were actually entered on the command line.argv[argc]is required to be a null pointer (§5.1.2.2.1/2).