C Reference function getenv()

The function getenv() of the stdlib.h will get the environment string.

Usage of getenv():

char * getenv ( const char * name );

The function will retrieve a C string that is containing a value of the environment variable, which is specified with the name argument.

Parameters:

The name of the variable that you want to get.

Return value:


If the requested variable is not part of the environment list, the function returns a NULL pointer.

Source code example of abort():


	#include<stdio.h>
	#include<stdlib.h>

	int main ()
	{
		char * ptr_path;
		ptr_path = getenv ("PATH");

		if (ptr_path!=NULL)
			printf ("The set path is: %s",ptr_path);

		return 0;
	}

This entry was posted in C Reference stdlib.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. Tweet This! Tweet This! or use to share this post with others.

Leave a Reply: