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
How many identifiers are there in c?
string reverse using recursion
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
Should I learn c before c++?
What are all different types of pointers in c?
praagnovation
Describe newline escape sequence with a sample program?
What are valid signatures for the Main function?
Is register a keyword in c?
How is a macro different from a function?
Is null valid for pointers to functions?
What are the advantages of Macro over function?
What is the value of c?
What are variables and it what way is it different from constants?
Why is a semicolon (;) put at the end of every program statement?