11 reputation
3
bio website Erfankam.com
location Islamic Repulic of, Iran
age
visits member for 2 years, 5 months
seen Jun 9 at 6:25

I am a Programmer.


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?