setenv(const char *name, const char *value, int overwrite);
is the function you need.
e.g. setenv("CONFIG_PATH", "/etc", 0);
From the man page:
DESCRIPTION
Thesetenv()
function adds the variablename
to the environment with the valuevalue
, ifname
does not already exist. Ifname
does exist in the environment, then its value is changed tovalue
if overwrite is nonzero; if overwrite is zero, then thevalue
ofname
is not changed. This function makes copies of the strings pointed to byname
andvalue
(by contrast withputenv(3)
).