Implementing the ls -al command in C

前端 未结 5 1803
误落风尘
误落风尘 2021-02-05 09:38

As a part of an assignment from one of my classes, I have to write a program in C to duplicate the results of the ls -al command. I have read up on the necessary materials but I

5条回答
  •  余生分开走
    2021-02-05 10:13

    The trouble is that when you stat("ankur.txt", &mystat), you are not working on the file "Downloads/ankur.txt". Most likely, the stat() is failing; alternatively, it is reporting on a different file.

    Consequently, you need to look at whether your system supports fstatat() — new in POSIX 2008 — or arrange to prefix the name of the file with name of the directory.

提交回复
热议问题