c - Can I change the getenv 's return value? -
i want know happened if change memory return getenv
i know not code. know setenv
way.
like:
char *new_path = "/home/user/dev/mytry1"; char *path = getenv("path");// assume there : path=/home/user/dev/mytry //now *path = "/home/user/dev/mytry" memcpy(path,new_path,strlen(new_path)+1);
is undefined behavior ? or wrong code?
i tried , no error or segmentation fault happened.
no, can't. documentation:
conforming applications required not modify environ directly, use functions described here manipulate process environment abstract object.
Comments
Post a Comment