Reputation
Top tag
Next privilege 15 Rep.
Flag posts
Badges
4
Impact
0 people reached

May
25
comment Why is cd not a program?
I think every process has a working directory and path variable too. Thus you by chdir just change this attribute of process. Shell has this attribute too and by cd we modify this attribure.
May
25
comment Why is cd not a program?
lets add some another lines to your app. #include <stdlib.h> int main(void) { chdir(".."); puts(getenv("PWD")); setenv(P"PWD", "/", 1); puts(getenv("PWD")); } What will we have as results?