I can't use setenv()
from stdlib.h
for C99 standard compiler as it is not available. Is there any other function to set an environment variable in C99?
相关问题
- Multiple sockets for clients to connect to
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
- Equivalent of std::pair in C
getenv
is thus part of the C90 standard which is included in C99 butsetenv
is only conform to an IEEE standard so it hasn't to be included in strictly standard C99. Moreover, the corresponding IEEE is from 2001.This means there isn't any standard way of doing this in C99, you have to use platform-specific code to set the env.
On the freebsd man page:
setenv
,putenv
and so on should be defined on any POSIX system.If you're using windows, see this other question which talks about
_putenv_s
.