How to retrive contents of environment variables?


Ans:. The following program shows how to achieve this:

main( int argc, char *argv[ ], char *env[ ] )

{

int i = 0 ;

clrscr( ) ;

while ( env[ i ] )

printf ( “\n%s”, env[ i++ ] ) ;

}

main( ) has the third command line argument env, which is an array of pointers to the strings. Each pointer points to an environment variable from the list of environment variables.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>