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

Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.

0 Answers  


What is advantage of pointer in c?

0 Answers  


What is operator precedence?

0 Answers  


What does the && operator do in a program code?

0 Answers  


why should i select you?

21 Answers   Wipro,






console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above

0 Answers  


What is string constants?

0 Answers  


code for bubble sort?

1 Answers  


Write program to remove duplicate in an array?

0 Answers  


Can we include one C program into another C program if yes how?

7 Answers   Infosys,


What is main () in c?

0 Answers  


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

0 Answers  


Categories