Created
August 7, 2021 07:11
-
-
Save alsamitech/8b2d466ef92450e6891c85741d6409e1 to your computer and use it in GitHub Desktop.
file_count- lists the amount of files in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file_count will add one to the count because zero is reserved for errors | |
size_t file_count(const char* dir_nm){ | |
DIR* dir=opendir(dir_nm); | |
if(!dir)return 0; | |
struct dirent* entity=readdir(dir); | |
size_t count=0; | |
for(;readdir(dir);count++); | |
closedir(dir); | |
return count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment