/* *@author cody *@date 2014-08-12 *@description */ /* extern char **environ //environment values #include <stdlib.h> char *getenv(const char *name); int setenv(const char *name,const char *value,int rewrite); // set enviroment if exists rewrite - 0 do not rewrite not 0 rewrite void unsetenv(const char *name); //delete env by name */ #include <stdio.h> #include <stdlib.h> void environment(){ extern char **environ; int i; for(i = 0;environ[i] != NULL;i ++){ printf("%s ",environ[i] ); } } void getPath(){ char *path = getenv("PATH"); printf("PATH = %s ",path ); setenv("PATH","HELLO",1); path = getenv("PATH"); printf("PATH = %s ",path ); } int main(int argc, char const *argv[]) { //environment(); getPath(); return 0; }