有没有办法用C语言改变目录?
有什么方法可以通过执行C 程序来更改到任何目录吗?
Is there any way by which I can change to any directory by executing a C program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有什么方法可以通过执行C 程序来更改到任何目录吗?
Is there any way by which I can change to any directory by executing a C program?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
chdir()
函数。有关更多信息,请使用man chdir
。The
chdir()
function. For more info, useman chdir
.根据您的操作系统的不同,更改当前目录的调用也不同。这些通常只会更改运行可执行文件的进程的当前目录。进程退出后,您将位于您开始时所在的目录中。
Depending on your OS there are different calls for changing the current directory. These will normally only change the current dir of the process running the executable. After the process exits you will be in the directory you started in.
chdir()
仅更改进程的当前工作目录,而不更改您正在工作的上下文。假设您在终端中执行一个程序,并且当前目录是/home/Documents
,那么执行具有以下几行的程序时不会更改终端的工作目录,但会更改进程的工作目录仅有的。
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 lineswill not change the working directory of the terminal, but changes that of the process only.
那么,用于更改当前目录的 POSIX 命令是:
请参阅 最新 POSIX 文档 < code>chdir() 在这里。
Well, the POSIX command for changing the current directory is:
See the recent POSIX documentation for
chdir()
is here.是的,chdir() 函数。
Yes, the chdir() function.
根据此
As per this