List files in directories using Glob() in C
问题 Basically, so far I have this code: #include <glob.h> #include <string.h> #include <stdio.h> # define ERROR 1 # define FAILURE -1 int main(int ac, char **av) { glob_t globlist; int i; i = 0; if (ac == 1) return (-1); else { if (glob(av[1], GLOB_PERIOD, NULL, &globlist) == GLOB_NOSPACE || glob(av[1], GLOB_PERIOD, NULL, &globlist) == GLOB_NOMATCH) return (FAILURE); if (glob(av[1], GLOB_PERIOD, NULL, &globlist) == GLOB_ABORTED) return (ERROR); while (globlist.gl_pathv[i]) { printf("%s\n",