Is there any way to change directory using C language?

后端 未结 6 1850
无人及你
无人及你 2020-11-27 08:24

Is there any way by which I can change to any directory by executing a C program?

6条回答
  •  生来不讨喜
    2020-11-27 08:58

    chdir() changes only the current working directory of the process but not of the context in which you are working. Suppose you execute a program in the terminal and your current directory is /home/Documents, then on executing a program having the following lines

    chdir("cd ../Downloads");
    

    will not change the working directory of the terminal, but changes that of the process only.

提交回复
热议问题