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
Where are local variables stored in c?
What will be your course of action for a push operation?
What does sizeof int return?
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array
Is that possible to add pointers to each other?
Explain how can I avoid the abort, retry, fail messages?
What is console in c language?
What is the difference between declaring a variable and defining a variable?
What do you mean by keywords in c?
What is difference between structure and union in c programming?
Ow can I insert or delete a line (or record) in the middle of a file?
in linking some of os executables are linking name some of them
What is c definition?
Explain how can you tell whether a program was compiled using c versus c++?
Why is python slower than c?