This should get you started...
Code:
#include <stdio.h>
#include <dirent.h>
main()
{
DIR* d_str;
struct dirent* dir;
if((d_str = opendir("/etc")) == NULL)
{
printf("Could not open directory");
exit(1);
}
while((dir = readdir(d_str)) != NULL)
{
printf("%-32s %d\n", dir->d_name, dir->d_ino);
}
}
Basically you #include <dirent.h> (look for it on your system...
slocate dirent.h). Calling opendir() returns a pointer to a
DIR stream, and readdir() returns a pointer to a
struct dirent. You call opendir once, and it returns NULL if it can't satisfy your request. You can call readdir repeatedly in a loop to get the entire contents of a directory. The first two entries will be "." and ".." respectively. I just googled for
<dirent.h> and found a page by the Open Group with info on the header.
edit: As Matir showed, you have your man pages available which I always forget about too
Code:
man opendir
man closedir
man readdir
man rewinddir
man scandir
etc... As you need to know more you can just follow the trail of man pages.