"B. Gandhi" wrote:
char *path = getenv("PATH");
In this call to getenv(), where does the returned string stored?
is it on heap or stack?
and do I need to make a call like free(path) when there is
no need for path anymore?
The following quote (from N869) tells you all you know or need to
know about the getenv function. Get a copy of the standard and
look these things up yourself.
7.20.4.4 The getenv function
Synopsis
[#1]
#include <stdlib.h>
char *getenv(const char *name);
Description
[#2] The getenv function searches an environment list,
provided by the host environment, for a string that matches
the string pointed to by name. The set of environment names
and the method for altering the environment list are
implementation-defined.
[#3] The implementation shall behave as if no library
function calls the getenv function.
Returns
[#4] The getenv function returns a pointer to a string
associated with the matched list member. The string pointed
to shall not be modified by the program, but may be
overwritten by a subsequent call to the getenv function. If
the specified name cannot be found, a null pointer is
returned.
--
Replies should be to the newsgroup
Chuck Falconer, on vacation.