It depends which operating system the program will be running on.

For Unix/Linux, look at the opendir(), readdir() and closedir() functions.
For Win32, it's FindFirstFile(), FindNextFile() and FindClose() functions.