Checking if a dir. entry returned by readdir is a directory, link or file. dent->d_type isn't showing the type

后端 未结 4 1462
一整个雨季
一整个雨季 2020-11-29 10:36

I am making a program which is run in a Linux shell, and accepts an argument (a directory), and displays all the files in the directory, along with their type.

Outpu

4条回答
  •  情话喂你
    2020-11-29 11:04

    Print d_type as an integer like so:

    printf("%d ", dent->d_type);
    

    and you'll see meaningful values.

提交回复
热议问题