Dch*_*ris 0 c linux directory bash shell
我想使用C文件中的代码更改unix中的目录.我试过这个:
char command[50];
strcpy( command, "cd newdirectory/" );
system(command);
Run Code Online (Sandbox Code Playgroud)
但它没有用.其他命令使用"系统"工作.
要更改目录,请尝试使用chdir.一个相关的问题是如何更改C中的工作目录?.关于使用系统参见为什么我们不能通过Linux中的system()系统调用来更改目录?和使用C++更改Linux中的当前目录.