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
What is array in c with example?
What is the difference between c &c++?
how can I convert a string to a number?
What is dangling pointer in c?
Write a program to identify if a given binary tree is balanced or not.
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Is it valid to address one element beyond the end of an array?
What is difference between stdio h and conio h?
What are multidimensional arrays?
What is const and volatile in c?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
Write a c program to build a heap method using Pointer to function and pointer to structure ?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What are logical errors and how does it differ from syntax errors?
Can a file other than a .h file be included with #include?