diff options
Diffstat (limited to 'ls.c')
-rw-r--r-- | ls.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -3,12 +3,19 @@ #include <stdlib.h> #include <sys/types.h> -int main(void) +int main(int argc, char **argv) { - struct dirent *dirent; + char *dirname; DIR *dir; + struct dirent *dirent; + + if (argc > 1) { + dirname = argv[1]; + } else { + dirname = "."; + } - dir = opendir("."); + dir = opendir(dirname); while ((dirent = readdir(dir)) != NULL) { fprintf(stdout, "%s\n", dirent->d_name); |