I notice that the C standard defines the getenv() function but that (7.22.4.2)
the method for altering the environment list [is]
implementation-defined.
I’m trying to have my program work on as many hosted C implementations as possible, is there a good general way to check if an implementation has a method to set an environment variable and what that method is, or will I have to take it on a case-by-case basis? Also, the wording of that quote suggests to me that there must be SOME method for each implementation, is that understanding correct?
It is possible to have an implementation of C on a system that does not have environment variables. So by that token you you cannot conclude that all host platforms support environment variables. However, that’s pretty much nitpicking. You will have to deal with this on a case by case basis but you’ll find
putenv()pretty much everywhere.