diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-03-17 03:55:21 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-03-17 03:55:21 +0000 |
commit | 77055d99e4fc6d319fa746d8730e5c6a484202e5 (patch) | |
tree | 3e6e7e33ce0ef28c70f49a92f1b0bf7ca9b65050 /manual/examples/dir2.c | |
parent | fb63ae13d021389b3e96bc1183ec7f84a054553a (diff) | |
download | glibc-77055d99e4fc6d319fa746d8730e5c6a484202e5.tar glibc-77055d99e4fc6d319fa746d8730e5c6a484202e5.tar.gz glibc-77055d99e4fc6d319fa746d8730e5c6a484202e5.tar.bz2 glibc-77055d99e4fc6d319fa746d8730e5c6a484202e5.zip |
New example for scandir function.
Diffstat (limited to 'manual/examples/dir2.c')
-rw-r--r-- | manual/examples/dir2.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/manual/examples/dir2.c b/manual/examples/dir2.c new file mode 100644 index 0000000000..e3157694bd --- /dev/null +++ b/manual/examples/dir2.c @@ -0,0 +1,29 @@ +/*@group*/ +#include <stdio.h> +#include <dirent.h> +/*@end group*/ + +static int +one (struct dirent *unused) +{ + return 1; +} + +int +main (void) +{ + struct dirent **eps; + int n; + + n = scandir ("./", &eps, one, alphasort); + if (n >= 0) + { + int cnt; + for (cnt = 0; cnt < n; ++cnt) + puts (eps[cnt]->d_name); + } + else + perror ("Couldn't open the directory"); + + return 0; +} |