setenv() to update PATH environment variable

view story

http://stackoverflow.com – i want to write a C program to append a string to PATH Environment variable. something like "export PATH=$PATH:$HOME/mylib" i have C code like this setenv("PATH", "$PATH:$HOME/mylib",1); //which does not work. other work arround i thought was get PATH and HOME using getenv() and create a memory in heap then append them using strcat(). I might have to update PATH many times in my code: so this is a tiresome process. is there any alternative? Thanks (HowTos)