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 pragma c?

0 Answers  


while initialization of array why we use a[][2] why not a[2][]...?

0 Answers   Aptech,


Do pointers store the address of value or the actual value of a variable?

0 Answers   Fidelity,


write a program to print data of 5 five students with structures?

0 Answers  


How do you print an address?

0 Answers   TCS,






where does malloc() function get the memory?

1 Answers  


1. Can we use the for loop this way? for(;i>5;) 2. What is the use of pointers? 3. what is array of pointer? 4. What is the difference between file and database? 5. Define data structure?

1 Answers  


What is the difference between struct and typedef struct in c?

0 Answers  


What is the use of define in c?

0 Answers  


What are the different file extensions involved when programming in C?

0 Answers  


what type of language is C?

13 Answers   Microsoft,


why effort estimation is important?

1 Answers  


Categories