Welcome to the Linux Foundation Forum!
environment variable in linux gcc
Hi,
I am able to get environment variable using getenv function in gcc.But when tried to change the value using setenv function, its value is changed as seen after calling getenv function. when try to seen the value of environment variable in command terminal in ubuntu. it is not showing any change. Can any one tell me, how can i change environment variable in linux gcc.
----------------
Linux Learner
0
Comments
I'm just getting back into a UNIX-type environment (yay, Mint!), so the only solutions to your problem that I remember is by (ugh! ugh!) running a root-level program that can manipulate system memory; or run a script or program that initializes the environment variables that you want to manipulate in a child process, then start another child process that will work with the environment variables.
Example:
#this is a script that sets up the variables that program "foo" will manipulate.
set RESULT1=' '
set RESULT2='0'
~/foo
echo $RESULT1
echo $RESULT2
# end shell script
Write a program (foo) that changes the environment variables, and the value of the changed variables will stay in effect until the shell script ends.