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
Why is c so popular?
What is 1f in c?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
Why is structure important for a child?
How do you initialize pointer variables?
why return type of main is not necessary in linux
What is the use of function in c?
what do u mean by Direct access files? then can u explain about Direct Access Files?
Is there any demerits of using pointer?
How do I use strcmp?
How can I manipulate strings of multibyte characters?
Can the size of an array be declared at runtime?
Is c high or low level?
Are comments included during the compilation stage and placed in the EXE file as well?
What is meant by gets in c?