A
A
alienstone2015-05-20 20:05:05
linux
alienstone, 2015-05-20 20:05:05

Why is the putenv function needed when we have an environ variable?

Hello
In the course of writing a program that will change the process environment, I came across the following question: why do we need the putenv () function and how can it radically differ from simple pointer access to the char ** environ variable?
What's the point of putting it in? If only security (in putenv there is a type check, as far as I understand), you can add a new environment variable using putenv () well, and banal convenience. Although, as for me, it doesn’t make much difference to put it in a separate function, for such reasons. Please explain the essence, I will be very grateful

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MiiNiPaa, 2015-05-20
@alienstone

why do we need the putenv() function
To add environment variables.
If the application modifies the pointers to which environ points, the behavior of all interfaces described in the System Interfaces volume of POSIX.1-2008 is undefined.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question