source:
tags/1.0/test/dir.c
@
5
Last change on this file since 5 was 5, checked in by willem, 11 years ago | |
---|---|
File size: 414 bytes |
Line | |
---|---|
1 | #include <errno.h> |
2 | #include <dirent.h> |
3 | #include <stdio.h> |
4 | #include <stdlib.h> |
5 | |
6 | int main() |
7 | { |
8 | DIR *pdir; |
9 | struct dirent *pent; |
10 | |
11 | pdir=opendir("."); //"." refers to the current dir |
12 | if (!pdir){ |
13 | printf ("opendir() failure; terminating"); |
14 | exit(1); |
15 | } |
16 | errno=0; |
17 | while ((pent=readdir(pdir))){ |
18 | printf("%s\n", pent->d_name); |
19 | } |
20 | if (errno){ |
21 | printf ("readdir() failure; terminating"); |
22 | exit(1); |
23 | } |
24 | closedir(pdir); |
25 | } |
Note: See TracBrowser
for help on using the repository browser.