View Single Post
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#8
Code:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

extern char **environ;

int main() {
  printf("environ[0]: %s\n", environ[0]);

  printf("PATH: %s\n", getenv("PATH"));

  if(!setenv("PATH", "/my/new/path", 1)) {
    printf("PATH: %s\n", getenv("PATH"));
  } else {
    printf("Could not change PATH variable!\n");
  }

  return 0;
}
 

The Following User Says Thank You to Joorin For This Useful Post: