Hi,
I want to know how can I change and check environment variables in a C program. For instance I want to check $HOME or $PATH an change them
Thanks in advance
Printable View
Hi,
I want to know how can I change and check environment variables in a C program. For instance I want to check $HOME or $PATH an change them
Thanks in advance
getenv() and setenv()
check your man pages for these functions.
It's putenv(). :D
setenv() gives you more control, check your man pages ;)Quote:
Originally Posted by jim mcnamara
But neither of them change the parent environment.
If you program does putenv("PATH=foo");
Then running the program does NOT change the PATH in your shell.
Because you are running in a child process.
Thanks guys. Linux rules