struct linkedString { char *value; struct linkedString *next; }; struct linkedString *fileList; struct dirent* entry; struct linkedString *fileListPointer = fileList; while ( (entry = readdir(dir)) != NULL) { fileListPointer = (struct linkedString*)malloc(sizeof(struct linkedString)); fileListPointer->value = entry->d_name; fileListPointer = fileListPointer->next; fileListPointer = NULL; printf("%s\n", entry->d_name); }