How to get the path to the current file (pwd) in Linux from C?

前端 未结 5 1463
走了就别回头了
走了就别回头了 2021-02-09 16:30

I\'d like to know if it is somehow possible to run system("pwd") on the current DIR. So for example let\'s have this folder structure:

exam         


        
5条回答
  •  遇见更好的自我
    2021-02-09 17:09

    You can use chdir(2) to change dir from C, then system("pwd"); will give you what ever directory you chdir'ed to.

    The C-equvivalent of the pwd-command is getcwd(3).

提交回复
热议问题