Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <dirent.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char* argv[], char* envp[])
- {
- int file_count = 0, symb_links = 0;
- DIR *dirp;
- struct dirent *entry;
- if (argc != 2)
- {
- printf("invalid input!\n");
- exit(-1);
- }
- dirp = opendir(argv[1]);
- if (dirp == NULL){
- printf("Can't open the directory!\n");
- exit(-1);
- }
- while ((entry = readdir(dirp)) != NULL) {
- if (entry->d_type != DT_DIR) {
- file_count++;
- }
- }
- closedir(dirp);
- printf("Number of files = %d\n", file_count);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement