No you cannot.
system()
is forking off a new process which then has its own environment. All changes it makes to it will not effect the environment of the parent process, so you won't notice any effect of a setenv
it might do (unless the child process does additional things after the setenv
). When the child process terminates (probably very quickly), then that changed environment is forgotten.
You are stuck with the proper setenv
call. Maybe you should ask a new question concerning your problems with that one.
To change the parent process's environment, the parent process has to change it. The child can only give information back to its parent which then will have to use this information. A typical way of doing such a thing is this:
Parent process (e. g. in a shell):
eval "$(child)"
Child process (e. g. in C):
printf("setenv ENVIRONMENT=%d\n", value+1);