Created
March 22, 2015 19:58
-
-
Save msg555/23e497de6d107f4ee4e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <dirent.h> | |
#include <stdio.h> | |
int main(int argc, char** argv) { | |
for (int i = 1; i < argc; i++) { | |
DIR* dir = opendir(argv[i]); | |
if (!dir) { | |
fprintf(stderr, "failed top open directory %s\n", argv[i]); | |
continue; | |
} | |
for(;;) { | |
dirent* ent = readdir(dir); | |
if (ent == NULL) { | |
break; | |
} | |
printf("%s\n", ent->d_name); | |
} | |
closedir(dir); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment