How to use S_ISREG() and S_ISDIR() POSIX Macros?
You’re using S_ISREG() and S_ISDIR() correctly, you’re just using them on the wrong thing. In your while((dit = readdir(dip)) != NULL) loop in main, you’re calling stat on currentPath over and over again without changing currentPath: if(stat(currentPath, &statbuf) == -1) { perror(“stat”); return errno; } Shouldn’t you be appending a slash and dit->d_name to currentPath … Read more