From 3c1b66f0b5bbc084b266bb3be8abb0843efb0fbb Mon Sep 17 00:00:00 2001 From: prnmxfqg4 Date: Thu, 7 Jul 2022 12:51:22 +0800 Subject: [PATCH] ADD file via upload --- myls1.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 myls1.c diff --git a/myls1.c b/myls1.c new file mode 100644 index 0000000..7863dc2 --- /dev/null +++ b/myls1.c @@ -0,0 +1,24 @@ +#include +#include + +#define NAME_MAX 80 +#include + +int main(int argc, char *argv[]) +{ + DIR *dir ; + struct dirent *de; + + if (argc != 1) + exit(1); + + if ((dir = opendir(".")) == NULL) + exit(1); + + while ((de = readdir(dir)) != NULL) + printf("%s\t", de->d_name); + + printf("\n"); + closedir(dir); + exit(0); +}