OpenExtensions for z/VM "Q"s and "A"s
Question:
Under many UNIX systems we access the environment variable table via a
parameter (envp) which is passed to a main program on the initial call.
Under OpenExtensions this seems not to exist. How do I find the value of all
environment variables which have been set in the shell prior to calling a
program when I don't know the names of these variables? If I did, then I
could obviously use getenv().
Response:
There is no third parameter (envp) to main() in OpenExtensions. Its use
is not portable. A more portable method is using the external environ
array. So if you have code like the following:
main(int argc, char **argv, char **envp)
it can be changed to:
extern char **environ;
#define envp environ
main(int argc, char **argv)
For more questions and answers, go to our
archive of questions and answers.
|