Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. // closedir(dir);
  2. // return 0;
  3. // char *dir = "./c/search";
  4. // FILE *file;
  5. // file = fopen(dir, "r");
  6.  
  7. // if(NULL == file)
  8. // {
  9. // perror(file);
  10. // return 1;
  11. // }
  12. // }
  13.  
  14. #include <stdio.h>
  15. #include <sys/types.h>
  16. #include <dirent.h>
  17. #include <string.h>
  18.  
  19. int main()
  20. {
  21. char *keywords="flag hello keyword";
  22.  
  23. DIR *dir;
  24. struct dirent *entry;
  25.  
  26. char *sy="./search/";
  27. dir = opendir(sy);
  28. if (dir == NULL)
  29. {
  30. perror("error dir open =(");
  31. return 1;
  32. }
  33.  
  34. while ( (entry = readdir(dir)) != NULL)
  35. {
  36. char *name = entry->d_name;
  37. printf("%s\n", name);
  38. if (strcmp(name,"..")==0 || strcmp(name,".")==0)
  39. {
  40. continue;
  41. }
  42. ///функции
  43. char way[50] = "./search/";
  44. strcat(way, name);
  45. printf("%s\n", way);
  46.  
  47. FILE *file;
  48. file = fopen(way,"r");
  49. if (file == NULL)
  50. {
  51. perror("error file open )=");
  52. return 1;
  53. }
  54.  
  55.  
  56. if (!EOF)
  57. {
  58.  
  59. }
  60.  
  61. else
  62. {
  63. continue;
  64. }
  65. fclose(file);
  66.  
  67. }
  68. closedir(dir);
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement