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 c is a procedural language?
Differentiate between full, complete & perfect binary trees.
What is an expression?
What are the types of i/o functions?
What is pass by reference in functions?
How can I split up a string into whitespace-separated fields?
What is the purpose of realloc()?
What are the advantages of external class?
Does * p ++ increment p or what it points to?
What language is c written?
What's the best way of making my program efficient?
What is the heap in c?
How variables are declared in c?
How can variables be characterized?
write a program to print data of 5 five students with structures?