void main(int argc,char *argv[],char *env[])
{
int i;
for(i=1;i<argc;i++)
printf("%s",env[i]);
}

Answer Posted / gaurav

It’s interesting.
This program reads environmental variables. It is as same as
"env" command in unix.
But program is not proper. i.e. if you pass n arguments to
program, then it reads n environmental variables only.
Try this program
void main(int argc,char *argv[],char *env[])
{
int i;
if (2 <=argc){
for(i=0;i<atoi(argv[1]);i++)
printf("\n%s",env[i]);
}else printf("\nPlease enter no. of env variables you want
e.g. 'a.out 5'\n");
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c so popular?

900


What is 1f in c?

2319


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

873


Why is structure important for a child?

850


How do you initialize pointer variables?

832


why return type of main is not necessary in linux

1900


What is the use of function in c?

952


what do u mean by Direct access files? then can u explain about Direct Access Files?

1859


Is there any demerits of using pointer?

832


How do I use strcmp?

846


How can I manipulate strings of multibyte characters?

836


Can the size of an array be declared at runtime?

834


Is c high or low level?

797


Are comments included during the compilation stage and placed in the EXE file as well?

895


What is meant by gets in c?

829