read the man page ($man scandir) for scandir. That should give you the info you want for your system.
Code:
int scandir (const char *dir, struct direct ***namelist,
int (*select) (const struct direct *),
int (*compar) (const struct direct **, const struct direct **));
here's a rough example (notethat if select is passed a NULL arguement, all names under the directory are placed in the arrary of direct structures.
Code:
#include <sys/dir.h>
#include <sys/param.h>
#include <stdio.h>
#include <string.h>
extern int alphasort ();
char pathname[MAXPATHLEN];
int main ()
{
int count, i;
struct direct** files;
strcpy (pathname, "/home/matt");
count = scandir (pathname, &files, NULL, alphasort);
if (count <= 0) {
fprintf (stderr, "No files in the directory \n");
exit (0);
}
printf ("Number of files = %d\n", count);
for (i = 1; i < count + 1; ++i )
printf ("%s\n", files[i-1]->d_name);
return 0;
}
Let me know if you don't understand anything after you read the man page...