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?<
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.