void main(int argc,char *argv[],char *env[])
{
int i;
for(i=1;i<argc;i++)
printf("%s",env[i]);
}
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / siddique
void main(int argc, char *argv[], char *env[])
{
int i=0;
while(env[i])
{
printf("%s\n", env[i]);
i++;
}
}
Is This Answer Correct ? | 2 Yes | 0 No |
what is a pointer
4 Answers Bank Of America, TCS,
Write a function that will take in a phone number and output all possible alphabetical combinations
Whats s or c mean?
What is function and its example?
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
if we take a number as a char then can we manipulate(add, subtract) on this number
how to swap 2 numbers in a single statement?
what does keyword ‘extern’ mean in a function declaration?
What are different types of pointers?
Are c and c++ the same?
Which is an example of a structural homology?
What is the role of this pointer?