dirent.h

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

醉酒当歌 提交于 2019-11-27 02:10:19
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. Output should be like this: << ./Program testDirectory Dir directory1 lnk linkprogram.c reg file.txt If no argument is made, it uses the current directory. Here is my code: #include <stdio.h> #include <dirent.h> #include <sys/stat.h> int main(int argc, char *argv[]) { struct stat info; DIR *dirp; struct dirent* dent; //If no args if (argc == 1) { argv[1] = "."; dirp = opendir(argv[1]); // specify directory here: "." is the "current

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

折月煮酒 提交于 2019-11-26 09:54:56
问题 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. Output should be like this: << ./Program testDirectory Dir directory1 lnk linkprogram.c reg file.txt If no argument is made, it uses the current directory. Here is my code: #include <stdio.h> #include <dirent.h> #include <sys/stat.h> int main(int argc, char *argv[]) { struct stat info; DIR *dirp; struct dirent* dent; //If no args if