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
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().
setenv() gives you more control, check your man pagesOriginally 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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Because you are running in a child process.
Thanks guys. Linux rules