I think what you are looking for is something along these lines
This is sort of copied out of "Practical Unix Programming" (Robbins&Robbins)
You should do man search on opendir, DIR*, dirent , closedir, readdir, 
#include <stdio.h> <stdlib.h> <string.h> dirent.h errno.h
DIR * dirp-- pointer to an opened dir
struct dirent *direntp -- pointer to a dir entry
dirp = opendir("name of dir");
while(direntp = readdir(dirp)) != NULL)
  printf("%s\n", direntp->d_name); // there's probably a lot more av than just the name
closedir(dirp)