chdir() not affecting environment variable PWD

后端 未结 3 1222
醉梦人生
醉梦人生 2020-12-20 19:59

When I use chdir() to change the current working directory, why doesn\'t the getenv(\"PWD\") give the present working directory? Do I need to setenv(\"PWD\",newDir,1) also?<

3条回答
  •  一向
    一向 (楼主)
    2020-12-20 20:28

    The PWD environment variable isn't automatically updated by chdir, so you'd have to do it explicitly using setenv. However, the getcwd function should still report the updated value automatically.

提交回复
热议问题