Untitled
unknown
plain_text
3 years ago
1.0 kB
1
Indexable
Never
#include <stdio.h> #include <string.h> #include <dirent.h> void traverseDirectories(const char* directory_name){ DIR* dir = opendir(directory_name); if(dir == NULL){ return; } struct dirent* entity; entity = readdir(dir); while(entity != NULL){ if(entity->d_type == DT_DIR && strcmp(entity->d_name, ".") != 0 && strcmp(entity->d_name, "..") != 0){ char path[100] = {0}; strcat(path, directory_name); strcat(path, "/"); strcat(path, entity->d_name); traverseDirectories(path); printf("%s\n", entity->d_name); } entity = readdir(dir); } closedir(dir); } int main(int argc, char* argv[]){ FILE *database_file; database_file = fopen("database.txt", "r"); string database2d[1000][3]; char buffer[256]; while (fgets(buffer, 256, database_file)){ printf("%d", strlen(buffer)); } fclose(database_file); traverseDirectories("."); return 0; }