C 编程中的 opendir()

opendir() in C Programming

我是初学者,正在编写有关获取文件目录的代码,但我有一些不明白的地方。

DS = opendir ("./");

中的"./"是什么意思

我搜索了很多关于 C 编程的站点,但没有一个给我很好的解释。我必须尽快展示我的代码,这迫使我解释我的每一行代码。请帮我。谢谢!

./ 是相对于您进程的 current working directory 的相对路径。

In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with each process. When the process refers to a file using a simple file name or relative path (as opposed to a file designated by a full path from a root directory), the reference is interpreted relative to the current working directory of the process.

所以假设你的进程的工作目录是/foo,当你用opendir打开./时,你实际上打开了/foo/./,它等于/foo.