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 time complexity c?

755


Explain how do you generate random numbers in c?

816


In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

2888


What are the data types present in c?

849


What is const and volatile in c?

792


What is header file in c?

833


Write a program to print “hello world” without using semicolon?

886


How can I change their mode to binary?

899


Are there namespaces in c?

790


What is the difference between c and python?

810


Why is c fast?

792


Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

845


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

811


Explain the difference between malloc() and calloc() function?

806


What is the difference between the local variable and global variable in c?

726