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

How many identifiers are there in c?

573


string reverse using recursion

1805


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

1594


Should I learn c before c++?

593


What are all different types of pointers in c?

568






praagnovation

1772


Describe newline escape sequence with a sample program?

645


What are valid signatures for the Main function?

694


Is register a keyword in c?

629


How is a macro different from a function?

652


Is null valid for pointers to functions?

603


What are the advantages of Macro over function?

1186


What is the value of c?

566


What are variables and it what way is it different from constants?

777


Why is a semicolon (;) put at the end of every program statement?

620