Skip to content

Instantly share code, notes, and snippets.

@sat0b
Created June 12, 2017 21:56
Show Gist options
  • Select an option

  • Save sat0b/e9c7977350fbc28a8ad89370f21b6650 to your computer and use it in GitHub Desktop.

Select an option

Save sat0b/e9c7977350fbc28a8ad89370f21b6650 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <dirent.h>
int main(int argc, char* argv[]) {
const char* directory;
if (argc < 2) {
directory = ".";
} else {
directory = argv[1];
}
DIR* dp = opendir(directory);
dirent* entry = readdir(dp);
while (entry != NULL) {
std::cout << entry->d_name << std::endl;
entry = readdir(dp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment