Guest User

Untitled

a guest
Dec 17th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # include <stdlib.h>
  2. # include <dirent.h>
  3. # include <sys/types.h>
  4. # include <stdio.h>
  5. int list(){
  6. char s[50];
  7. struct dirent *entry;
  8. printf("Specify directory for list of filesn");
  9. scanf("%s", &s);
  10. DIR *dir = opendir(s);
  11. FILE* ff;
  12. if (dir){
  13. printf("nn******nn");
  14. while ((entry = readdir(dir)) != NULL) {
  15. ff = (fopen(entry->d_name, "r"));
  16.  
  17. if (ff != NULL){
  18. printf("%sn",entry->d_name);
  19. fclose(ff);
  20. }
  21. else if (ff == NULL) {
  22. printf("%s(directory)n",entry->d_name);
  23. }
  24.  
  25. }
  26. printf("n******n");
  27. closedir(dir);
  28. return 1;
  29. }
Add Comment
Please, Sign In to add comment