C - getenv

10. March 2012 08:00

 

A C example to use getenv to get and print an enviroment variable.

 

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

int main(int argc, char **argv) {

	char *var = getenv("HOME");
	
	if (var == NULL)
		printf("Not Set");
	else
		printf("var = %s\n", var);

	return 0;
}

E-mail Kick it! DZone it! del.icio.us Permalink