Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 array in c with example?

1177


What is the difference between c &c++?

1101


how can I convert a string to a number?

1037


What is dangling pointer in c?

1148


Write a program to identify if a given binary tree is balanced or not.

1101


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1331


Is it valid to address one element beyond the end of an array?

1130


What is difference between stdio h and conio h?

1329


What are multidimensional arrays?

1075


What is const and volatile in c?

994


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

3140


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4630


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1667


What are logical errors and how does it differ from syntax errors?

1241


Can a file other than a .h file be included with #include?

1110