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


Please Help Members By Posting Answers For Below Questions

What is the difference between text and binary modes?

648


What is integer constants?

625


What is actual argument?

591


Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

604


What is the default value of local and global variables in c?

560






What is data structure in c and its types?

597


How do I determine whether a character is numeric, alphabetic, and so on?

623


Write a code of a general series where the next element is the sum of last k terms.

596


What is pointer and structure in c?

575


What is the scope of local variable in c?

578


How can I manipulate individual bits?

608


When c language was developed?

642


What type of function is main ()?

590


What is the explanation for modular programming?

688


What are the uses of null pointers?

591