Getenv() error when invoked more than one time
<p>I have codes to get environment variable name from stand input and call library function <code>getenv()</code> to get the value and output.</p>

<p>Here are codes.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;

#define MAXLEN 256

int main(void)

{
    char *envName;
    char *envValue;
    char *envEntry;
    char *envVar=(char*)malloc(sizeof(char)*MAXLEN);

    while(NULL!=(envName=gets(envVar))){

    envValue=getenv(envName);
    if(envValue){
        printf("%s\n",envValue);

        envEntry=strtok(envValue,";");

        while(envEntry){
            printf("%s\n",envEntry);

            envEntry=strtok(NULL,";");
        }
    }else{
        printf("not found\n");
    }
}

    return 0;
}
</code></pre>

<p>If the environment variable <code>"path"</code> contains <code>"a;b;c;d"</code>.
While it runs,if type a string "path" first time,it works well,but if type "path" again it only gets the first string like<code>"a"</code> or <code>"a;b"</code>.</p>