#include #include #include #include #include int main(int argc, char** argv) { const char* pathname; if (argc == 1) pathname = "/"; else pathname = argv[1]; DIR* dp = opendir(pathname); if (!dp) { perror("opendir"); return 1; } bool first_ent = true; do { struct dirent* ent = readdir(dp); if (!ent) break; printf(first_ent ? "%s" : " %s", ent->d_name); first_ent = false; } while (1); printf("\n"); closedir(dp); return 0; }