opendir() in C Programming

家住魔仙堡 提交于 2021-02-19 16:32:13

问题


I'm a beginner and I am making a code about getting the directory of a file, but I have something that I don't understand.

What's the meaning of "./" in DS = opendir ("./");

I have searched a lot of sites about C programming, but nothing gave me a good explanation. I have to present my code soon, forcing me to explain every single line of my code. Please help me. Thanks!


回答1:


./ is a relative path which is relative to the current working directory of your process.

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.

So suppose the working directory of your process is /foo, when you open ./ with opendir, you are actually opening /foo/./ which is equal to /foo.



来源:https://stackoverflow.com/questions/27728052/opendir-in-c-programming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!