Rename htable_delete() to htable_remove()
[eleutheria.git] / fileops / listdir.c
blob57381b13171b6677e1ffb426f8f22096a9e727de
1 /* compile with:
2 gcc listdir.c -o listdir -Wall -W -Wextra -ansi -pedantic */
4 #include <dirent.h>
5 #include <stdio.h>
6 #include <stdlib.h>
8 int main(int argc, char *argv[])
10 struct dirent *pdent;
11 DIR *pdir;
13 /* check argument count */
14 if (argc != 2) {
15 fprintf(stderr, "Usage: %s directory\n", argv[0]);
16 exit(EXIT_FAILURE);
19 /* open directory named by argv[1], associate a directory stream
20 with it and return a pointer to it
22 if ((pdir = opendir(argv[1])) == NULL) {
23 perror("opendir");
24 exit(EXIT_FAILURE);
27 /* get all directory entries */
28 while((pdent = readdir(pdir)) != NULL)
29 printf("%s\n", pdent->d_name);
31 closedir(pdir);
32 return EXIT_SUCCESS;