The getenv function uses a statically declared character buffer in which to
put the value of the environment variable that you passed in as an
argument. This means that you may sometimes get odd behaviour if
you try to manipulate the pointer that getenv returns or modify the
contents of the buffer. The solution is to copy the string to a
buffer you have declared.
Also, you should probably follow the instructions in the man page for
strtok and not use it. You will then need to write your own code
for traversing the character buffer.