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
What is the difference between text and binary modes?
What is integer constants?
What is actual argument?
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.
What is the default value of local and global variables in c?
What is data structure in c and its types?
How do I determine whether a character is numeric, alphabetic, and so on?
Write a code of a general series where the next element is the sum of last k terms.
What is pointer and structure in c?
What is the scope of local variable in c?
How can I manipulate individual bits?
When c language was developed?
What type of function is main ()?
What is the explanation for modular programming?
What are the uses of null pointers?