Can I change the getenv 's return value?
I want to know what exactly will happened if I change the memory return
from getenv
I know this is not a good code. I know setenv by the way.
Like:
char *new_path = "/home/user/dev/myTry1";
char *path = getenv("PATH");// assume there is : PATH=/home/user/dev/myTry
//now *path = "/home/user/dev/myTry"
memcpy(path,new_path,strlen(new_path)+1);
Is this a undefined behavior ? Or just a wrong code?
I tried it and no error or segmentation fault happened.
No comments:
Post a Comment