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



void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s&quo..

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

void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s&quo..

Answer / msrambabu

i need answer and explation to env function

Is This Answer Correct ?    3 Yes 1 No

void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s&quo..

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

Post New Answer

More C Interview Questions

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

0 Answers   Motorola,


Whats s or c mean?

0 Answers  


What is function and its example?

0 Answers  


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

0 Answers  


if we take a number as a char then can we manipulate(add, subtract) on this number

2 Answers  


how to swap 2 numbers in a single statement?

3 Answers  


what does keyword ‘extern’ mean in a function declaration?

1 Answers   Emerson,


What are different types of pointers?

0 Answers  


Are c and c++ the same?

0 Answers  


Which is an example of a structural homology?

0 Answers  


What is the role of this pointer?

0 Answers  


Categories