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 the difference between printf and scanf in c?
Can you define which header file to include at compile time?
What are register variables in c?
What are examples of structures?
Why can arithmetic operations not be performed on void pointers?
Tell me what is the purpose of 'register' keyword in c language?
What is the use of typedef in structure in c?
What is oops c?
What is the data segment that is followed by c?
What is p in text message?
Compare and contrast compilers from interpreters.
Why c is a mother language?
explain what are pointers?
Explain high-order bytes.
Can a variable be both static and volatile in c?