Try to use putenv() instead of setenv(). A little substrac of the manpage says:
"The setenv() function inserts or resets the environment variable name in the current environment list. If the variable name does not exist in the list, it is inserted with the given value. If the variable does exist, the argument overwrite is tested; if overwrite is zero, the variable is not reset, otherwise it is reset to the given value."
A question, when you said zero, you are talking about zero character right?. You have to put a string there.